Robot Buggy Module 3 – Initial Checkout and Basic Tests

Motor Direction Controls

The flow of electrical current in a direct-current (DC) motor controls the direction of rotation. Our robot Motor Driver Module switches the current-flow direction with an H-Bridge circuit, controlled digitally by the Raspberry program through the gpiozero Robot Class. 
Verify the motor direction and left-/right- hand assignments using the Python code here, or similar.

Speed Control

A robot’s motors can do more than just change direction: Pulse-Width-Modulation (PWM) is an effective technique for Motor Speed Control

The listing speed_control.py shows how. Line 8 sets up a loop, in this case counting down from 10 to 4. The speed is set in line 9 using robot.value, with the left value setting the left motor speed, and the right value setting the right. Values go from zero to 1, so divide by 10. Negative values go backwards. Lines 12 to 15 do some turns with more precise control than the robot.left or robot.right commands. These will be handy for sensors.