How the Maneuver Tests Work

Both the cyberbot and feedback360 modules have to be added to the micro:bit file system for the script to work.  In the maneuver tests you just finished, both scripts were included in the .hex file speeds_forward_left_right_backward.hex. Keep in mind that the feedback360 module is not included in .py files for the activities throughout the other cyber:bot tutorials, and would need to be added!

For a reminder on how to add ado that, see Add modules to your micro:bitPro tip: you can always reopen a script that had the modules added and was as a .hex file.  That way, you won’t have to add modules every time.  You can just open a previous app and then give it a new name before you start changing it.  For a refresher on this, see Save & Edit Scripts.

How the speeds_forward_left_right_backward Script Works

Below the name comment, the script imports both the cyberbot and feedback360 modules.

# speeds_forward_left_right_backward

from cyberbot import *
from feedback360 import *

 

A call to drive.connect is required to start the Feedback 360° built into the cyber:bot board.

drive.connect()

 

The drive.speed(64, 64) call starts the Feedback 360° servos turning at 1 turn/second.  Then, sleep(2000) makes sure the wheels continue to turn for 2 seconds.  

drive.speed(64, 64)             # Forward
sleep(2000)

 

The drive.speed(-64, 64) call makes the left servo turn backwards and while the right servo continues to roll forward.  The result is that the cyber:bot turn to the left by rotating in place.  The sleep(1000) makes sure the wheels continue this maneuver for 2 seconds.  

drive.speed(-64, 64)            # Rotate left
sleep(1000)

 

This next bit below is just the turn right version of the previous routine.  

drive.speed(64, -64)            # Rotate right
sleep(1000)

 

Compare this to the first maneuver.  Instead of positive values, it has negative values.  The result is that both wheels reverse.  

drive.speed(-64, -64)           # Backward
sleep(2000)

 

Setting the speeds to zero makes the servos stay still, bringing the cyber:bot to a stop.  

drive.speed(0, 0)


Try This: Going Faster

Try changing the forward and backward speeds to +/- 96.  This should make the cyber:bot roll 1.5x faster!

  • Modify the script as shown below by changing the forward and backward drive speeds.
  • Change the Script Name and comment to speeds_forward_left_right_backward_try_this.
  • Click Save to cownload a copy of your work.
  • Reconnect your cyber:bot to USB.
  • Set the PWR switch to 0
  • Flash the script into the cyber:bot
  • Disconnect the cyber:bot from the USB cable.
  • Set it on the floor and set the PWR switch to 2.
  • Verify that the forward and backward speeds increased.