MicroMod Machine Learning Carrier Board Hookup Guide

Pages
Contributors: Nate, Ell C
Favorited Favorite 2

Example 2: Accelerometer

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

SparkFun has written a library to work with the LIS2DH12 Accelerometer that's included on this board. You can obtain this library through the Arduino Library Manager by searching for "LIS2DH12". Find the one written by SparkFun Electronics and install the latest version. If you prefer downloading libraries manually, you can grab them from the GitHub Repository. We've linked the datasheet for the accelerometer in the Resources and Going Further section, but if you'd like it handy, you can also refer to it here.

With your library installed, navigate to the examples located under File->Examples->SparkFun LIS2DH12 Arduino Library. Let's load up Example1_BasicReadings to get you started.

File->Examples->SparkFun LIS2DH12 Arduino Library

Having a hard time seeing? Click the image for a closer look.


Making sure you have the correct board and port selected, go ahead and upload your code. Once the code finishes transferring, open the serial monitor and set the baud rate to 115200. You should see x y and z locations flying by, telling you the directions the accelerometer is reading!

Accelerometer serial output

Having a hard time seeing? Click the image for a closer look.