Chapter 12. Robots
Robots are cute in an “all humans must die” sort of a way; and, thanks to the educational uses of devices like the micro:bit, many makers have created robots that demonstrate how robotics can be a relatively simple and fun endeavour. This chapter explores two robotics projects that show how to use MicroPython to make your very own robotic invasion. Both use the micro:bit, although the techniques discussed are easy to transfer to other boards running MicroPython.
This bot trundles around on wheels. It has an analog distance sensor on the front to detect objects in its way. If something blocks its way, it rotates left or right until no blockage is detected, then it continues on its way. It’s a very simple bot that can be made in about an hour with only a few parts. The code to drive the bot is also beautifully simple and demonstrates how to drive servo motors to give the bot movement.1
The bot was successfully used in a bot-building workshop at EuroPython 2016 and, because of its simplicity, was easy to modify and change to suit the available building materials and aims of the builders (who included experienced Python programmers, their nontechnical partners, and children).
The minimum parts required are inexpensive:
- A micro:bit
- 2 9g continuous rotation servos
- A Pololu Carrier with Sharp GP2Y0A60SZLF Analog Distance Sensor, 3 V
- 2 wheels
- A Pololu caster ball
- A portable power source to provide between 3.3 V and 4.2 V
There also needs to be some means ...