Go Down

Topic: 5DOF with Arduino Uno (Read 550 times) previous topic - next topic

jlu92

Hi I am currently working on a project that will take readings from the IMU and transmit them to my computer for further processing. The 5DOF contains an ADXL335 and an IDG500, at the momment I am not really concerned with the Gyro aspect, and just want to focus on getting the accelerometer working properly. Here is a list of the connections:

X-Acc -> A0
Y-Acc -> A1
Z_Acc -> A2
ST      -> Unconnected
VRef   -> Unconnected
Y-Rate -> A4
x-Rate -> A5
GND    -> GND (from Uno)
3.3V   -> 3.3V (from Uno)

Code: [Select]
// these constants describe the pins. They won't change:
const int xpin = A0;                  // x-axis of the accelerometer
const int ypin = A1;                  // y-axis
const int zpin = A2;                  // z-axis (only on 3-axis models)

void setup()
{
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop()
{
  // print the sensor values:
  Serial.print(analogRead(xpin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(ypin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(zpin));
  Serial.println();
  // delay before next reading:
  delay(100);
}


for an output of the serial i am getting:
230   227   228
230   227   229
232   228   228
232   229   229
232   229   231
232   228   230
234   231   230
233   230   231
233   230   231
234   230   229
235   231   231
233   230   231
234   230   231
235   231   231
235   232   231
235   231   232
237   232   231
236   234   233
236   233   233
236   233   233
238   234   232
237   234   234
238   234   234
238   234   233
These numbers don't change when the device is moved or shaken.  Do I have something wired incorrectly? Is my IMU broken?
any input is appreciated Thanks!!

MarkT

You're code is broken, you don't want to be using The Arduino Mega address pin numbers (A0..A7), replace this
Code: [Select]
const int xpin = A0;                  // x-axis of the accelerometer
const int ypin = A1;                  // y-axis
const int zpin = A2;                  // z-axis (only on 3-axis models)

by this:
Code: [Select]
const int xpin = 0;                  // x-axis of the accelerometer
const int ypin = 1;                  // y-axis
const int zpin = 2;                  // z-axis (only on 3-axis models)
[ I won't respond to messages, use the forum please ]

Go Up