Arduino Forum

Using Arduino => Project Guidance => Topic started by: njkl44 on Mar 30, 2011, 08:31 am

Title: Accelerometer and Servo control
Post by: njkl44 on Mar 30, 2011, 08:31 am
Alright if i have an accelerometer at default position i want a servo to be at the middle most point (90 degrees if 180 degree rotation). When i move the accelerometer to the left i want the servo to fallow to movement, so when the accelerometer is at -90 degrees the servo is at -90 degrees. Same as if one is at -45 degrees the other one is the same. My question is how would i code this. i have looked at accelerometer code but am just unsure of how to control the servo the way i stated. Also would a gyroscope do a better job of this?

Thank You, Easton
Title: Re: Accelerometer and Servo control
Post by: AWOL on Mar 30, 2011, 12:05 pm
Quote
so when the accelerometer is at -90 degrees the servo is at -90 degrees

-90 degrees relative to what?

Remember, an accelerometer only measure acceleration, so only your acceleration is due to gravity, your movement will normally have an accleration pahase, and an equal and opposite decceleration phase.