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 '192.168.1.21/robot?s1=90&s2=90&s3=90&s4=90&m=0' sleep 1 wget '192.168.1.21/robot?s1=120&s2=90&s3=120&s4=0&m=0' 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.
Conclusion
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.
Infos
« Previous 1 2 3 Next »
Buy this article as PDF
Pages: 8
(incl. VAT)