Go Down

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

nazrdogan

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

Code: [Select]

const int XPin = A0; // X
const int YPin = A1; // Y
const int ZPin = A2; // Z

const int X0 = 337;  // Adjust to raw 0g value for X
const int Y0 = 337;  // Adjust to raw 0g value for Y
const int Z0 = 337;  // Adjust to raw 0g value for Z

// Sensitivity:  Volts per G
const float Xsens = 0.800 * 5.0 / 1023.0; // Adjust to get 1.0 at 1g
const 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

thank you very much.. ? will try

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