Hardware Reference
In-Depth Information
{ 200 , 0 , 0 }, // red
{ 200 , 200 , 200 }, // white
};
// don't edit the line below
#define FAVCOLORS sizeof(myFavoriteColors) / 3
// mess with this number to adjust TWINklitude :)
// lower number = more sensitive
#define MOVE_THRESHOLD 45
void setup ()
{
Serial . begin ( 9600 );
// Try to initialise and warn if we couldn't detect the chip
if ( ! accel . begin ())
{
Serial . println (
"Oops ... unable to initialize the LSM303.
Check your wiring ! ");
while ( 1 );
}
strip . begin ();
strip . show (); // Initialize all pixels to 'off'
}
void loop ()
{
/* Get a new sensor event */
sensors_event_t event ;
accel . getEvent ( & event );
Serial . print ( "Accel X: " );
Serial . print ( event . acceleration . x ); Serial . print ( " " );
Serial . print ( "Y: " );
Serial . print ( event . acceleration . y ); Serial . print ( " " );
Serial . print ( "Z: " );
Serial . print ( event . acceleration . z ); Serial . print ( " " );
// Get the magnitude (length) of the 3 axis vector
// http://en.wikipedia.org/wiki/Euclidean_vector#Length
double storedVector =
event . acceleration . x * event . acceleration . x ;
storedVector += event . acceleration . y * event . acceleration . y ;
storedVector += event . acceleration . z * event . acceleration . z ;
Search WWH ::




Custom Search