Although we do not wish to dwell on the mechanical aspects of this project, the LEGO motor is worth mentioning. Within the compact housing are both a small motor and a very efficient gearbox. The motor is fairly expensive, but you’ll immediately appreciate how much more quietly it runs than cheaper gearboxes. Because the motor draws only approximatly 100 mA, it is perfect for use with our micro motor controller.
To use the LEGO motors in you own project, you need to get leads that you can connect to your own electronics. One possibility is to cut a regular LEGO cable in half and solder on male header pins onto the cut wires. This will give you the two necessary connectors at the expense of one LEGO cable.
We built the electronics on a small solderless breadboard. As you can see from the close-up picture to the right, there isn’t much to the circuit. The only components other than the BASIC Stamp II and the motor controller are the two pull-up resistors for the bumper switches. The schematic diagram for this circuit is shown below.
Using the BASIC Stamp II is very convenient because all of its I/O lines are interchangeable; the only reason we used the particular pins indicated in the schematic is because it made the wiring convenient. The Stamp’s on-board voltage regulator allows it to run straight off of a 9-volt battery, and the LEGO motors are designed to run at 9V as well. The Stamp’s regulated 5V output is used for the motor controller’s logic power supply. The diagram does not show the Stamp’s 12 I/O lines available for expansion.