Go Down

### Topic: MMA7361 accelerometer problem (Read 823 times)previous topic - next topic

#### nazrdogan

##### Mar 24, 2012, 10:02 pm
hi everyone..
I have  MMA7361 accelerometer.I try many of code.but I cannot measure acceleration truly. please help me .. can you  give me some example code.

#### johnwasser

#1
##### Mar 25, 2012, 12:14 am
Code: [Select]
`const int XPin = A0; // Xconst int YPin = A1; // Yconst int ZPin = A2; // Zconst int X0 = 337;  // Adjust to raw 0g value for Xconst int Y0 = 337;  // Adjust to raw 0g value for Yconst int Z0 = 337;  // Adjust to raw 0g value for Z// Sensitivity:  Volts per Gconst float Xsens = 0.800 * 5.0 / 1023.0; // Adjust to get 1.0 at 1gconst float Ysens = 0.800 * 5.0 / 1023.0;const float Ysens = 0.800 * 5.0 / 1023.0;float Xg = 0;float Yg = 0;float Zg = 0;void setup() {Serial.begin(9600);}void loop() {unsigned int Xraw = analogRead(XPin);unsigned int Yraw = analogRead(YPin);unsigned int Zraw = analogRead(ZPin);Xg = (Xraw - X0) * Xsens * 5.0 / 1023.0;Yg = (Yraw - Y0) * Ysens * 5.0 / 1023.0;Zg = (Zraw - Z0) * Zsens * 5.0 / 1023.0;Serial.print("Xraw=");Serial.print(Xraw);Serial.print(" Xg=");Serial.print(Xg);Serial.print(" Yraw=");Serial.print(Yraw);Serial.print(" Yg=");Serial.print(Yg);Serial.print(" Zraw=");Serial.print(Zraw);Serial.print(" Zg=");Serial.println(Zg);delay(200);}  `
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

#### nazrdogan

#2
##### Mar 25, 2012, 08:16 pm
thank you very much.. ? will try

Go Up