I am new to this and was wondering if anyone has had success connecting a ADXL321 Dual Axis Accelerometer Breakout Board - ADXL321 +/-18g - SEN-00848 - SparkFun Electronics and reading serial port data?
Some sample code would really help me get started.
Cheers
This is the code that I have at the moment:
But the readings are at 1022 & 1023?
/* Accelerometer read and print values to serial port
*
*/
char messageline[80] = "";
int ledPin = 13;
int xPin = 1;
int yPin = 2;
int valX = 0;
int valY = 0;
void setup()
{
Serial.begin (9600);
pinMode(xPin, INPUT);
pinMode(yPin, INPUT);
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
digitalWrite(13,HIGH); //turn on debugging LED
}
void loop()
{
valX = analogRead(xPin);
valY = analogRead(yPin);
Serial.print("X: ");
Serial.println(valX, DEC);
Serial.print("Y: ");
Serial.println(valY, DEC);
//delay (250);
Serial.print(10,BYTE);
}
Skott