Script & Tests

Let’s start with a simple app, like forward_three_seconds from Forward and Backward in the Navigation with the cyber:bot chapter.  After following the four steps, the updated script might look like forward_three_seconds_for_fb360 (below).

  • Make sure there are five AA batteries in your cyber:bot robot’s battery pack and that it’s plugged into your cyber:bot board.
  • Connect the micro:bit in the cyber:bot to your computer with a USB cable.
  • Set the PWR switch to 1.
  • If you have not done so already, right-click the feedback_360_template.hex link below and choose Save As, then open it with the python.microbit.org/v/2 editor.

feedback_360_template.hex

  • Enter the forward_three_seconds_for_fb360 script shown below.
  • Click Load/Save, then select Download Project Hex to save your work.
  • Click Connect.
  • Click Flash.
  • Set the PWR switch to 0.

 

Example Script: forward_three_seconds_for_fb360

# forward_three_seconds_for_fb360

from cyberbot import *
from feedback360 import *           # <-- add

drive.connect()                     # <-- add

# bot(18).servo_speed(75)           # <-- comment Half speed forward
# bot(19).servo_speed(-75)          # <-- comment
drive.speed(37, 37)                 # <-- add

sleep(3000)                         # Wait three seconds
 
# bot(18).servo_speed(None)         # <-- comment Stop
# bot(19).servo_speed(None)         # <-- comment
drive.speed(0, 0)                   # <-- add

 

Tests

  • Disconnect the cyber:bot’s micro:bit from the USB cable.
  • Set it on the floor
  • Set the PWR switch to 2.
  • Verify that the cyber:bot travels forward for 3 seconds and then stops.