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: Radio Tilt Control

Cybersecurity: Radio Tilt Control

Update the Receiver cyber:bot Script

The transmitter micro:bit should still be running the same script from the previous activity.  That’s radio_tilt_controller_w_stop_range.

Now for the new cyber:bot receiver script!

Example script: radio_tilt_bot_fb_lr_with_stop_range

  • Set the cyber:bot board’s PWR switch to 0.
  • Make sure you are working in the browser with the micro:bit Python Editor that is connected to the radio tilt controlled cyber:bot.
  • If the radio_tilt_bot_fb_with_stop_range script isn’t already open, click Open, and find and open it.
  • Change the project name to radio_tilt_bot_fb_lr_with_stop_range. 
  • Update the script to match the one below.
  • If you are in a classroom, adjust the channel= in the script to your assigned channel.
  • Click Save, and then click Send to micro:bit.  
# radio_tilt_bot_fb_lr_with_stop_range

from cyberbot import *
import radio

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

while True:

    packet = radio.receive()

    if packet:

        dictionary = eval(packet)

        x = dictionary.get('x')
        y = dictionary.get('y')
        needle = dictionary.get('needle')
        
        fb = y / 10
        lr = x / 10

        if abs(fb) > 8:
            display.show(Image.ALL_CLOCKS[needle])
            vL = fb
            vR = -fb

            if(fb < 0): lr = -lr
            vL = vL - lr
            vR = vR - lr

        else:
            display.show(Image.DIAMOND_SMALL)

        bot(18).servo_speed(vL)
        bot(19).servo_speed(vR)   
  • Set the cyber:bot board PWR switch to 1.
  • Repeat the needle/diamond display tests from the previous activity.
  • Set the cyber:bot board PWR switch to 2.
  • Now, tilt the micro:bit transmitter in the directions shown in the table, and verify that the cyber:bot moves as expected:

 

Tilt the micro:bit transmitter Verify the cyber:bot maneuver
Level Stay still
Slightly away from you Forward slowly
Further away from you Forward faster
Slightly toward you Slowly backward
Further toward you Faster backward
Away from you and to the left Curve forward and to the left
Away from you and to the right Curve forward and to the right
Toward you and to the left Curve backward and to the left
Toward you and to the right Curve backward and to the right

Printer-friendly version
Add Left/Right Tilt Control
Prev
How the Receiver Works
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress