hi!
i'm trying to run arduino (with atmega328) with Accelerometer freescale MMA7260, i bought the accelerometer with sureelectronics pcb board
i've connected the gnd to gnd, vdd to 3v3, X to analog 00, Z to analog 01, and y to analog 02.
here is the code of the program:
void setup()
{
Serial.begin(9600);
}
void loop()
{
static int Xaxis = 0 ;
static int Yaxis = 0 ;
static int Zaxis = 0 ;
static int Xaxisold = 0 ;
static int Yaxisold = 0 ;
static int Zaxisold = 0 ;
static int Xaxisold1 = 0 ;
static int Yaxisold1 = 0 ;
static int Zaxisold1 = 0 ;
Xaxis = analogRead(0);
if(Xaxisold != Xaxis)
{
Xaxisold1 = Xaxis;
Xaxis -= Xaxisold;
Serial.println("X =");
Serial.println(Xaxis);
}
Xaxisold = Xaxisold1;
//Serial.print(Xaxis, BYTE);
delay(10);
Zaxis = analogRead(1);
if(Zaxisold != Zaxis)
{
Zaxisold1 = Zaxis;
Zaxis -= Zaxisold;
Serial.println("Z =");
Serial.println(Zaxis);
}
Zaxisold = Zaxisold1;
delay(10);
Yaxis = analogRead(2);
if(Yaxisold != Yaxis)
{
Yaxisold1 = Yaxis;
Yaxis -= Yaxisold;
Serial.println("Y =");
Serial.println(Yaxis);
}
Yaxisold = Yaxisold1;
delay(100);
}
here is the output:
X =
191
Z =
24
Y =
23
X =
-1
Y =
-1
Y =
1
X =
1
X =
-1
Y =
-1
Z =
1
X =
1
Y =
1
X =
-1
Y =
-1
no matter how i move it , it seems like it doesn't responds and there's just noise, does any one know's what im i doing wrong?