The Arduino takes its power from (and transmits data through) a USB port.

====Development Environment====

====Development Environment====

I wrote and uploaded my code to the Arduino and accelerometer using the [http://arduino.cc/hu/Main/Software Arduino 1.0 IDE] on Ubuntu 11.04. Help for getting the integrated development environment running on Ubuntu can be found [http://arduino.cc/playground/Linux/Ubuntu here]. The language is very similar to C.

I wrote and uploaded my code to the Arduino and accelerometer using the [http://arduino.cc/hu/Main/Software Arduino 1.0 IDE] on Ubuntu 11.04. Help for getting the integrated development environment running on Ubuntu can be found [http://arduino.cc/playground/Linux/Ubuntu here]. The language is very similar to C.

-

====ADXL345 and Arduino 1.0 IDE====

+

When the program is running, the Arduino must remain hooked up to the USB port. The serial monitor in the IDE must be turned on, as this is where the data will output.

+

==== ====

+

To write code for the ADXL in Arduino 1.0, one needs to have a library containing a .cpp and a .h file. The library is inserted into the libraries folder in the Arduino 1.0 directory. Essentially, a library contains subroutines one may find useful in writing their code and helps a programmer interface with a device, without having to worry about all the details.

+

I used an [http://code.google.com/p/adxl345driver/downloads/list ADXL 345 library] that I found on a bildr tutorial.

+

====Code====

+

This is the code I used to take in data from the ADXL345. Parts of the code from a [http://bildr.org/2011/03/adxl345-arduino/ bildr tutorial] were reused.

+

<source lang ="c">

+

#include <Wire.h>

+

#include <ADXL345.h>

+

ADXL345 adxl; //variable adxl is an instance of the ADXL345 library

+

int x,y,z;

+

float Gx, Gy, Gz;

+

int count=0;

-

<source lang ="c">

+

void setup(){

-

init.h

+

Serial.begin(9600);

+

adxl.powerOn();

+

adxl.setRangeSetting(2); //G sensing range from -2g to +2g

+

+

//set activity/ inactivity thresholds (0-255)

+

adxl.setActivityThreshold(75); //62.5mg per increment

+

adxl.setInactivityThreshold(75); //62.5mg per increment

+

adxl.setTimeInactivity(6); // how many seconds of no activity is inactive?

Circuit

I connected the ADXL to the Arduino using a relatively simple circuit. I used the circuit setup from a bildr tutorial. The accelerometer came mounted on a breakout board, with holes where pins could go. I had to solder pins onto the breakout board

Arduino 3.3 v is connected to ADXL VCC and CS

Arduino ground is connected to ADXL ground

Arduino Analog In 4 (A4) is connected to ADXL SDA

Arduino Analog In 5 (A5) is connected to ADXL SCL

The Arduino takes its power from (and transmits data through) a USB port.

Development Environment

I wrote and uploaded my code to the Arduino and accelerometer using the Arduino 1.0 IDE on Ubuntu 11.04. Help for getting the integrated development environment running on Ubuntu can be found here. The language is very similar to C.

When the program is running, the Arduino must remain hooked up to the USB port. The serial monitor in the IDE must be turned on, as this is where the data will output.

To write code for the ADXL in Arduino 1.0, one needs to have a library containing a .cpp and a .h file. The library is inserted into the libraries folder in the Arduino 1.0 directory. Essentially, a library contains subroutines one may find useful in writing their code and helps a programmer interface with a device, without having to worry about all the details.