Accelerometer Table using Arduino Esplora

Accelerometer Table

This example simplifies the task of collecting data from the Esplora’s accelerometer and graphing it with your computer.

Accelerometer Table

The Esplora sends keypresses to a connected computer about the state of the accelerometer. If you open a spreadsheet application, you can log the data from the accelerometer.

To start and stop the datalogging, press the down pushbutton. The Esplora’s LED will indicate the state of the logging. The slider is used to set the sampling interval.

Circuit

Only your Arduino Esplora is needed for this example.

Accelerometer Table

Esplora datalogging setup

Code

In this example, the Esplora acts as a keyboard; once the you press the down button, it will send characters to a connected computer.

The characters sent to the computer are formatted to fit inside a spreadsheet’s rows and colums. Each row of the spreadheet will contain a timestamp and the 3 accelerometer axis readings.

To start sampling, press the direction down push-button. This begins communication as a keyboard with the computer. Changing the position of the linear potentiometer will change the rate at which samples are read from the accelerometer and written to the computer.

/*

Esplora Table

Acts like a keyboard that prints sensor

data in a table-like text, row by row.

At startup, it does nothing. It waits for you to open a

spreadsheet (e.g. Google Drive spreadsheet) so it can write

data. By pressing Switch 1, it starts printing the table

headers and the first row of data. It waits a bit, then it

will print another row, and so on.

The amount of time between each row is determined by the slider.

If put to full left, the sketch will wait 10 seconds; at

full right position, it will wait 5 minutes. An intermediate

position will make the sketch wait for some time in-between.

Clicking the Switch 1 at any time will stop the logging.

The color LED shows what the sketch is doing:

blue = idle, waiting for you to press Switch 1 to start logging

green = active; will print soon

red = printing data to the PC

Created on 22 november 2012

By Enrico Gueli <enrico.gueli@gmail.com>

modified 24 Nov 2012

by Tom Igoe

*/

#include <Esplora.h>

/*

* this variable tells if the data-logging is currently active.

*/

bool active = false;

/*

Read more: Accelerometer Table using Arduino Esplora

Leave a Comment

Your email address will not be published. Required fields are marked *