Go Down

Topic: adxl 335 code (Read 2157 times) previous topic - next topic

uink

I'm trying to connect a adxl 335 to my arduino uno.  I followed the directions on this site

http://michaelabrahamsen.com/10/2010/using-the-adxl335-accelerometer-with-arduino/

and used the code listed there, but my serial monitor isn't giving me numbers, only a bunch of gibberish. 

anyone know what's wrong?

Thanks

AWOL

You've got the wrong bit rate set?
You've got a TTL to RS232 conversion issue?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

uink

I got a different code, and now it is working. 
Thanks

AWOL

And what was the problem (so that others may learn from your experience) ?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

uink

#4
Jun 20, 2011, 03:34 pm Last Edit: Jul 11, 2011, 06:08 pm by uink Reason: 1
I'm not sure what the problem was!!!
However, here is how i hooked it up as well as my code:adxl 335-arduino uno
st-A0
z-A1
y-A2
x-A3
gnd-A4
vcc-A5

My code is:

Code: [Select]
/*
 
This example code is in the public domain.

*/

// these constants describe the pins. They won't change:
const int groundpin = 18;             // analog input pin 4 -- ground
const int powerpin = 19;              // analog input pin 5 -- voltage
const int xpin = A3;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A1;                  // z-axis (only on 3-axis models)

void setup()
{
  // initialize the serial communications:
  Serial.begin(9600);
 
  // Provide ground and power by using the analog inputs as normal
  // digital pins.  This makes it possible to directly connect the
  // breakout board to the Arduino.  If you use the normal 5V and
  // GND pins on the Arduino, you can remove these lines.
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);
}

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);
}

Thank you so much!!!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy