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 0.

Example Script: forward_three_seconds_for_fb360

  • 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 micro:bit Python Editor editor.

feedback_360_template.hex

  • Enter the forward_three_seconds_for_fb360 script shown below.
  • Click Save, then click Send to micro:bit.
# 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.