Using the ESP8266 as a micro-controller for servomotors

Arming Up

Starting up the arm can be quite tricky. First, you have to find out the starting positions of the levers for each servo, which is tedious and time-consuming. It's best to start from the bottom up.

Unfortunately you cannot rely on the positions given in the above examples as these will vary depending on how you set up your own robot arm. You'll need to work out which values correspond to which angles yourself. The command in Listing 2, for instance, moves the arm upwards while the bottom servo will angle downward towards your work surface.

It's not easy to control the robot arm through the web browser. The wget command can help with this, allowing you to invoke URLs from the command line. Listing 3 shows a small extract from the instructions for the "Tower of Hanoi" puzzle. The entire script is fairly lengthy as you need a separate statement for each movement of the arm.

Listing 3

Extract of "Tower of Hanoi" movements

wget ''
sleep 1
wget ''
sleep 1

As you can see from the above code snippet, each wget command is followed by sleep 1 so that the servos have time to move. The final two commands from the full "Tower of Hanoi" script move the arm back to the starting position and deactivate the servomotors so it won't draw any more power.

You can find the complete script, named moves along with a video of the arm in action on the magazine DVD.


The overall aim of this project was to show you how easy it is to control servos with an ESP8266. You also learned about the "Tower of Hanoi" puzzle and that it's not so easy to bring about the end of the world. You've also gained some insight into robotics. Controlling a robot is far from easy, but this project is an excellent starting point for your own servomotor project.

The Author

Martin Mohr was born during the era of rare earth magnet memory and Strowger switches. At an early age, he fell in love with anything that blinked. After getting a degree in computer science, his work primarily involved the development of Java applications. The Raspberry Pi has re-awakened his earlier fascination with electronics.

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content