Accelerometer Controlled Robotic Hand

This is my first post on Treehouse Projects, and I hope it will be the beginning of a lot more to come in the future.

Prosthetic body parts have always intrigued me. The research I have witnessed and read about in the field has always inspired me to try and find solutions to assist people with disabilities. By no means is this project an innovative step in that direction, but it is a first for me, and I hope future versions will be much more practical and potentially useful from a functional and economical standpoint.

This project is simply a system of two servos controlled via an accelerometer, meant to imitate the hand gestures of the individual holding the device. It gives the “hand” two degrees of freedom. The entire system is controlled by a microcontroller (Arduino clone).

Resources Required

For the general hobbyist, most of these parts would be readily available. The key components I used were:

  1. Microcontroller (any will do really, you’ll need at least 4 IO pins, 2 being analog if your accelerometer requires them like mine do; I used an Arduino clone, find my code below)
  2. Servos (you’ll need 2; I use the HXT900 as I have them lying around when I build planes)
  3. Accelerometer (I chose the MMA7361 because it was cheap, and analog is always easier to work with; other alternatives like the ADXL345 are great too)
  4. Solderless breadboard or PCB (I chose solderless because I will reuse the parts)
  5. Wood (I used 6mm ply; you can experiment with different materials, doesn’t matter much)

This project took me about six hours to complete. It shouldn’t have taken that long, but I am a beginner when it comes to 3D modeling and woodworking. An unexpected twist in the software also caused delays.

The total cost came out to be approximately $15 (excluding the microcontroller).

Sketches & Images

These are pictures of the model I drew in Sketchup, as well as what they physically resulted in:

robohand robohand
robohand robohand
robohand robohand


I used my 3D sketches to measure and cut the wood. I used a scroll saw on a board of 6mm ply, and put the parts together.

Connecting the components was quite simple. For the MMA7361 accelerometer, I had it on default sensitivity settings, and only used the XY analog outputs. I wasn’t expecting my model to fall off the desk, so I didn’t need the Z output (although it would be funny if I did use it, and programmed the hand to break the fall!). Do note that I also utilized the SL (sleep pin) on 3.3V. The servos were connected to the 5V rail, and connected to the digital pins of the microcontroller.

Note: It was fine controlling one servo via a laptop’s USB connection with the microcontroller, but take caution to always connect it to an external power source for anything more. In retrospect, it’s a lesson learned for me, and I will make doubly sure to always use an external power source going forward. USB ports typically don’t provide more than 500ma anyways.

Other problems came in when I connected my servos and accelerometer all together to the microcontroller. Alone, the accelerometer gave very accurate and stable results. I viewed these results over the serial print display at a baud rate of 9600. However, once I connected the servos, some sort of disturbance or interference which I’m still trying to triangulate caused the accelerometer to randomly produce spikes and/or dips in its readings, even when sitting perfectly still on my desk. I was forced to jury rig a simple algorithm to smooth out these jittery movements.

See my code for more details, but what I essentially did was wait for an anomaly to occur, and if it did not occur for more than 2 readings, then ignore the readout and use a previously stored value. This algorithm ended up creating a few variables to toy with in order to find an ‘optimal’ combination to minimize jitter. The reason it checks for 2 readings is because the anomaly could genuinely be someone moving the accelerometer – as you can imagine, this also causes a very slight, albeit noticeable, delay in responsiveness. If anyone can suggest a potential cause for the atypical readouts when I connect the servos, I would appreciate it.


What went wrong? Well, a lot of things actually. Foremost was the jittery movement of the servos, which was partly solved by the code to smooth the movement. Second was the size of the housing of the servos: it was too small. I misjudged it significantly, but ended up using a child’s glove to work equally well (see video). Third, the inability to mount the accelerometer on my hand – it was a little too big, and I didn’t want to solder it all up.

What would improve it? I was actually aiming to ‘wear’ the accelerometer, so next time I might try a cheaper surface mount version of it on a custom PCB. This was a really rough first prototype, so I’m still relatively satisfied. Next, servos are simply too inaccurate. I would like sub-degree accuracy, and will definitely strive to utilize stepper motors (I have 2 small ones with driver boards on the way now).

Next steps? Improve accuracy and stability, gradually add more degrees of freedom eventually leading up to a full arm sometime in the future, and add the simple ability to grasp objects. My initial idea was to make a small robotic hand which could be programmed by copying the motion of a human arm, and complete tasks which one would find monotonous after ‘seeing’ the user perform it once.



Thank you to the authors of the following pages I referenced to help me build this project:

  • Sebarduino for tips on how to operate the MMA7361 – written in French, but easy enough to read it if it’s your … um … third language ;)
Posted in Projects
9 comments on “Accelerometer Controlled Robotic Hand
  1. I am starting to be a BIG fan of your cute ideas!

    I have been working with servos and accelerometers for ages and never thought of doing that!

  2. filip says:

    hey friend the code that was here was very good with the basis for making me a different code so you could relocate disponiblea sight?

  3. filip says:

    ahhh sorry thing is that the code for this project robotic hand helped me on a previous project and now I am in the same case, just that I have not your code available,could help me =??

    estoy elaborando un brazo, intento controlar los servomotores con el acelerometro MMA7361 utilizando los tres ejes pero no me resultan mis codigos

    I’m developing an arm, trying to control the servomotors using accelerometer MMA7361 three axis but I find my codes

    thank´s very much my friend

    god bless you !!

    • Hi Filip,

      I can certainly help you, though I must admit, I’m still not quite understanding what exactly you need my help with. I mean, if you just want the code, it’s still right there in my post.

      Is there some specific help with the code which you require?

      Again, I’m really sorry. I hope I can help you out, sounds like you have an interesting project.

  4. FILIP says:

    clear! this was for Morelos State Fair DGTI senior high, I am in the 6th semester of my high school.

    but the teacher told us that no matter who a bag of fried crickets aiga we removed haha.
    The CENAND take us to this in the state of Mexico.

       (this is a clear arm takes 5 servomotors, one at the base three joints., and one as Griper or hand.) the code you placed in me served much for my code to send the arduino that like to control my servo my accelerometer. I need to move to another sensor mimano comfortably! .

  5. Abhishek Kanchan says:

    can u tell me what can be the possible applications of an accelerometer controlled robot

    • Treehouse Projects says:

      There are incredible applications for an accelerometer controlled robot! Mostly for autonomous robotics, an IMU (inertial measurement unit) is used on a robot. The IMU consists of an accelerometer (gives information about linear acceleration), a gyroscope (information about rotational acceleration), and a magnetometer (detects magnetic fields, can be used as a compass). All three sensors combined give you a very good picture of the object you attach an IMU to in three dimensions. So you know exactly how your object/robot is oriented at all times. Now, suppose you are making a robot which is going over rough terrain and its position is constantly unstable. Knowing what its position is will allow you to make corrections in the robot’s operation to maintain stability. Also, say the robot topples over on its side, if you know the rate of acceleration of the robot when it topples over, you can predict this event ahead of time and run a corrective algorithm to prevent this.

      Data from sensors like accelerometers are heavily used in control systems, where you are constantly feeding back on an error in some measurement. Say your robot is carrying a delicate payload of some sort, and you detect a sudden acceleration. With that data, you can actually do something to minimize or completely eliminate the movement.

      There are just so many applications, it’s hard for me to list them all.

Leave a Reply

Your email address will not be published. Required fields are marked *