Lilypad - Accelerometer


accelerometer.jpg
Lilypad Accelerometer

Description:

Senses acceleration in three directions - side-to-side (x), forwards and backwards(y), up and down (z). Returns three values each with a range of between 0 and 1023. Can be used as a tilt sensor as well as a movement sensor.

Connecting:

1. Connect the positive petal on the Accelerometer to the positive petal on the Lilypad Main Board.
2. Connect the negative petal on the Accelerometer to the negative petal on the Lilypad Main Board.
3. Connect the "X" petal on the Accelerometer to one of the analog input petals on the Lilypad Main Board e.g. "a0".
4. Connect the "Y" petal on the Accelerometer to one of the analog input petals on the Lilypad Main Board e.g. "a1".
5. Connect the "Z" petal on the Accelerometer to one of the analog input petals on the Lilypad Main Board e.g. "a2".

NB: If you are using alligator leads to prototype then make sure that the teeth of your clips make good contact with the metal parts of the sensor petals. If not, you will get inconsistent results.
accelerometerConnect.jpg
Accelerometer Connected to Lilypad

Getting Data From:

Getting data from any analog input involves writing a sketch to read that input using the anlogRead() function. A good basic example of this is the Arduino example AnalogInSerial sketch (File > Examples > Analog > AnalogInSerial). This sketch will read any analog input and then output the result to the serial monitor. This is a good way to check the range of values that your sensor is giving. To use it with the accelerometer you will need to add two more analog read functions as in the picture below. Note: The serial print out will be quite hard to read with all three values. Try commenting out the different print values to isolate each axis one-by-one. This will make it a bit easier to see what effect your movement is having.


tripleanalodinput.gif
Analog Input Example Sketch Adapted for Accelerometer


Links: