Driving forward and back
Our motors are attached, and the robot is looking ready to power up. First, we’ll use CircuitPython to make test code to try each motor in turn. Then, when we have demonstrated the motors running, we’ll make simple code to drive the motors straight forward and then back.
Testing each motor with CircuitPython
We will start driving our robot by looking at how we connected our Raspberry Pi Pico to our motors in the following figure:
Figure 5.1 – Motor connections from Raspberry Pi Pico
Figure 5.1 shows a closer look at the robot motor connections. On the left is Raspberry Pi Pico with four connections to the motor controller. They are on GPIO 16, 17, 18, and 19. These connections result in the motor controller powering the motor via one of the motor wires. Testing each of the Pico pins should cause a motor to do something.
Let’s try this with some code, setting up one motor, and making it drive in a...