Go Down

Topic: Arduino + Accelerometer: Tilt Detection (Read 30281 times) previous topic - next topic


what are these values :

long xy_max = 470;
long xy_min = 550;


what are these values :

long xy_max = 470;
long xy_min = 550;

These are the limits for the values to use in the "if" statements.

They are backwards, as you can tell (max < min), but that's really just semantics.

What happens is a set of if statements check to see if the accelerometer x and y outputs are greater than (in this case) the min, or less than the x, and light up the led's accordingly.


Sir where we can buy that kind of Accelerometer? Thanks for reply


Great post, thanks for sharing. I'm looking forward to trying this with an MMA3671L, which is 3-axis. I'm sort of unclear how you derived your constants (xy_max and xy_min). Were these part of the specification for your chip, or did you derive these experimentally by just tilting the board around and looking at outputs on serial? Thanks!


So, I did this using just the X and Y accel pins from a 5dof board (http://www.sparkfun.com/products/9268), and had to recalibrate the xy_min and xy_max to:

long xy_max = 300;
long xy_min = 350;

...but got it working!

I did the recalibration by just examining the serial output for each pin as I moved the board in space and noting the values as I moved it:



Good day! Sir can you post the schematic of your project. We will make a project like this. Thanks



Cool, nice to see my project is still being reused.

Sorry I didn't get back to you sooner, I don't monitor this thread.

Here's the link to the accelerometer I used:


The code is self explanatory, I think, but if anyone needs a schematic PM/email me and I'll draw one up.


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!

via Egeo 16
Torino, 10131