Two on-board Texas Instruments DRV8838 motor drivers power the Balboa’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.
Note that “forward” refers to the rotation direction that would cause a balancing Balboa to move in the direction its battery cover is facing.
The Balboa32U4 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 (VSW) 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.6) or using the encoders and other sensors to monitor the movement of the robot.