Two on-board Texas Instruments DRV8838 motor drivers power the Zumo 32U4’s two micro metal gearmotors. Four Arduino pins are used to control the drivers:
- Digital pin 15, or PB1, controls the right motor direction (LOW drives the motor forward, HIGH drives it in reverse).
- Digital pin 16, or PB2, controls the left motor direction.
- Digital pin 9, or PB5, controls the right motor speed with PWM (pulse width modulation) generated by the ATmega32U4’s Timer1.
- Digital pin 10, or PB6, controls the left motor speed with PWM.
The Zumo32U4 library provides functions that allow you to easily control the motors, and it can optionally take care of flipping a direction signal for you if you accidentally soldered in a motor backwards (see Section 6).
As your batteries run out, the voltage supplied to the motor drivers (VBAT) will decrease, which will make the motors slower. It is possible to account for this in your code by monitoring the battery voltage (see Section 3.8) or using the encoders and other sensors to monitor the movement of the robot.