Example Code for Arduino-Read Accelerometer Data
Hardware Preparation
- Triple Axis Accelerometer MMA7260 (SKU: DFR0068), Quantity: 1
- Arduino, Quantity: 1
- IO Expansion Shield For Arduino(V5) (SKU: DFR0088), Quantity: 1
- Analog Sensor Cable For Arduino (SKU:FIT0031), Quantity: 1
Wiring Diagram

The diagram consist of the following items:
Sample Code
For Arduino
//Arduino Sample Code
//Developed by DFRobot.com
//Last Modified 30/11/2011
//Version 1.0
void setup()
{
Serial.begin(19200); // 19200 bps
}
void loop()
{
int x,y,z;
x=analogRead(0);
y=analogRead(1);
z=analogRead(2);
Serial.print("x= ");
Serial.print(x ,DEC);
Serial.print(',');
Serial.print("y= ");
Serial.print(y ,DEC);
Serial.print(',');
Serial.print("z= ");
Serial.println(z ,DEC);
delay(100);
}
Was this article helpful?
