Have you ever thought about what direction a car’s wheels have to turn to propel it forward? The wheels turn opposite directions on opposite sides of the car. Likewise, to make the cyber:bot go forward, its left wheel has to turn counterclockwise, while its right wheel turns clockwise.
Remember that a script can use the servo_speed function to control the speed and direction of each servo. Then, it can use the sleep function to keep the servos running for certain amounts of time before choosing new speeds and directions. Here’s an example that will make the cyber:bot roll forward for about three seconds, and then stop.
# forward_three_seconds from cyberbot import * bot(18).servo_speed(75) # Full speed forward bot(19).servo_speed(-75) sleep(3000) # Wait three seconds bot(18).servo_speed(None) #Stop bot(19).servo_speed(None)
Now, let's try making the cyber:bot travel backwards for three seconds.
# backward_three_seconds from cyberbot import * bot(18).servo_speed(-75) # Full speed backwards bot(19).servo_speed(75) sleep(3000) bot(18).servo_speed(None) # Stop bot(19).servo_speed(None)