Programming

Plug in a USB cable connecting your Flora to your computer.
Download the Adafruit_LSM303 library from Github by clicking the ZIP button. Unzip the downloaded file and rename the resulting folder "Adafruit_LSM303," then move it to your Arduino libraries folder.

We have a very detailed tutorial on installing Arduino libraries here, so please read it if you are having difficulties installing the library right!
Open the special Adafruit version of the Arduino IDE and naviate to File-->Examples-->Adafruit_LSM303-->Test to open the accelerometer test sketch. For more information on programming the Flora, check out the Getting Started with FLORA guide.

Be sure you have the correct serial port and board type selected under the Tools menu, then upload the sketch to your Flora.
Open the serial monitor and watch the accelerometer values pour in!
Modify this sample sketch to integrate this sensor into your project. Debugging over USB is helpful to see the ranges of numbers your sensor provides, but once your code is solid, you can disconnect from the computer and power your project with a 3xAAA battery holder.
This guide was first published on Feb 05, 2013. It was last updated on Feb 05, 2013. This page (Programming) was last updated on Jul 21, 2019.