Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Cybersecurity: Navigation Control from a Keyboard

Cybersecurity: Navigation Control from a Keyboard

Receiver Script for cyber:bot Output

The receiver script is also adapted from a previous tutorial.

Starting with the countdown_receiver.py from the Send and Receive Packets activity, you can replace its countdown while loop and printed message with the servo_speed and sleep(ms) calls from terminal_controlled_bot_tethered_try_this.  You will also need to update the dictionary parsing so that it gets the vL, vR, and ms values using the ‘vL’, ‘vR’, and ‘ms’ keys.  That’s the most crucial part of incorporating the radio-in to cyber:bot navigation-out part of your tethered app into script that wirelessly receives.  

Here’s a GIF showing the modification taking place:

(View full-size: terminal_controlled_bot_wireless.mp4)

You will also need to make a few other adjustments.  Here they are step-by-step:

  • Open terminal_controlled_bot_tethered_try_this.
  • Copy these lines:
        bot(18).servo_speed(vL)
        bot(19).servo_speed(-vR)
        sleep(ms)
        bot(18).servo_speed(None)
        bot(19).servo_speed(None)
  • Open countdown_receiver from Send and Receive Packets.
  • Paste the three lines you copied over these lines:
        print("value = ", value)
        print("message = ", message, "\n")
        
        while value >= 0:
            print(value)
            sleep(1000)
            value = value - 1
            
        print(message)
  • Make sure the cyberbot.py module is added to the project.
    (See Add modules to your micro:bit).
  • Set the project name to terminal_controlled_bot_wireless.
  • Change from microbit import * to from cyberbot import *.
  • Find these two lines:
        value = dictionary['start']
        message = dictionary['after']
  • Replace them with these three lines:
        vL = dictionary['vL']
        vR = dictionary['vR']
        ms = dictionary['ms']
  • Update the comment at the top of the script with the name terminal_controlled_bot_wireless.
  • Delete these two lines:
        print()
        print("Parse: ")
  • Find these two lines:
        print("Countdown App")
        print("micro:bit sender")
  • Replace them with this line:
        print("Ready...\n")
  • Change the 50 in this line to 64:
        radio.config(channel=7,length=50)

It should look like this:

        radio.config(channel=7,length=64)
  • If you are in a classroom and using assigned channels, update your channel. 

Now, your script should be ready.  

  • Verify the changes you made against the example script listed below.
  • Disconnect your transmitter micro:bit from USB.
  • Connect the cyber:bot you will be remote controlling.
  • Click Save, then click Send to micro:bit.
  • Disconnect your cyber:bot from USB and set it on the floor somewhere nearby.
  • Make sure the:
    • Batteries are plugged in
    • Battery pack’s barrel plug is firmly plugged into the cyber:bot board’s barrel jack.
    • cyber:bot board’s PWR switch is set to 2.

Example script: terminal_controlled_bot_wireless

# terminal_controlled_bot_wireless

from cyberbot import *
import radio

radio.on()
radio.config(channel=7,length=64)

sleep(1000)

print("Ready...\n")

while True:
    packet = radio.receive()
    if packet is not None:
        print("Receive: ", packet)

        dictionary = eval(packet)

        vL = dictionary['vL']
        vR = dictionary['vR']
        ms = dictionary['ms']
        
        bot(18).servo_speed(vL)
        bot(19).servo_speed(-vR)
        sleep(ms)
        bot(18).servo_speed(None)
        bot(19).servo_speed(None)

 


Printer-friendly version
Transmitter Script for Keyboard Inputs
Prev
Test It: Navigate Wirelessly
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress