Let's Make Robots!

Accelerometer controlling 2 servos

Good Evening Everyone, 

What I am trying to do is use an accelerometer (http://www.sparkfun.com/commerce/product_info.php?products_id=847) to control two seperate servos (http://www.servocity.com/html/s3003_servo_standard.html), I was thinking I would use this microcontroller (http://www.sparkfun.com/commerce/product_info.php?products_id=666). (Are these all compatible?) 

The idea is balance a platform in a dynamic equilibrium with the two servos, as on if it rotates clockwise (0 to 90 degrees) in the x axis, it would move servo a in the positive direction, and servo b in the negative direction.

likewise on the same x axis if the platform rotated counterclockwise, servo a would move in the negative direction, and servo b would move in the positive direction.

Also there will be movement in the y axis(0 to 90 degrees). In a manner such that if the board starts to rotate forward servos a AND b will both move in the positive direction, and if it starts to rotate backward, servos a AND b will both move in the negative direction.

Will the microcontrolled be able to accept those signals and send out the proper balance to each servo? (As in there will movement in x and y axis at the same time, which will mean each servo has two inputs)

For example if movement in the x axis tells servo a to rotate 30degrees clockwise, but movement in the y axis tells it to move 15 degrees counterclockwise, will the end result be a rotation of 15 degrees clockwise like I need it to be?


Hope this can be understood.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I tink it sld be doable, u'll need the servo and analogread functions.


what do you mean by assembled? for the accelerometer from dimension engineering, the component is as shown in the pic.


I'm not really sure about the gounding part. Just connect to the power source??? What power source r u using?

can all this be programmed into the arduino opensource programming that they offer? Which I believe is similar to C?


On a side note would these components be assembled on just a standard pc board like the ones at radioshack. Also, what is a good way to ground out the microcontroller? 

u can try saving the old value and do a comparison with the new value, if it's within +- tolerance, then dun move, else, move servo.

As for sensitivity, very little is required. As the object will rotate up to a max of 90 degrees (through normally will only be around 45) in each direction.

In fact due to how much vibration the object will encounter, I was thinking some sort of delay should be programmed into the microcontroller as to help eliminate jittering. As I am just trying to compensate for excessive roll, not tiny vibrations.

this video uses 2 servos to control the platform

It depends on how much resolution you require. for tilt sensing, 2 g is more than enough.


the arduino feature a 10 bit ADC, which means the reading will be from 0 to 1024, so the resolution is .0117 g.


the one i used was from parallax, it comes with a 12 bit ADC, so u can just connect it to an digital I/O.

Thank you thats a good idea, as for the accelerometer, as an optional replacement I was looking at this one http://www.dimensionengineering.com/DE-ACCM6G.htm, have you had any experience with it/will it still work in conjunction with the microcontroller?

sld be ok, but i tink instead of having 2 inputs for 1 servo, u can try combining the 2 values (value = Servo1 + Servo2) and sent out the result to the servo. Of course, this is not fool proof, u'll need to make sure it stay within the min and max range.


My experience with the parallax accelerometer was that these devices are very sensitive, so if connected to the servos, it might result in jittering.