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

Radio-Receive Tilt

The radio_tilt_receive_test script is a modified version of countdown_receiver from the Cybersecurity: Radio Data’s Send and Receive Packets activity.  To receive and display tilt, it is adjusted to parse x, y, and needle values from the packet it receives, and then use statements from  display_tilt_down_with_leds to display the tilt with its LEDs and in the terminal.

Hardware Setup

  • Set the cyber:bot board’s power (PWR) switch to Position 0.
  • Make sure the battery holder is loaded with 5 AA batteries.
  • Make sure the battery holder’s barrel plug is firmly plugged into the cyber:bot board’s barrel jack.
  • Connect the cyber:bot to your computer with a USB cable.

Software Setup

  • In a Google Chrome or Microsoft Edge browser, go to python.microbit.org to open the micro:bit Python Editor.
  • Make sure the cyberbot.py module is added to the Project Files.
    (See Add modules to your micro:bit).
  • If you have each micro:bit connected to a different computer, skip to Example script: radio_tilt_receive_test.
  • If you have both micro:bit tilt controller and tilt controlled cyber:bot connected to USB Ports on the same computer:
    • Click the three dots   ⋮   by the Send to micro:bit button, then select Connect.  Then, set up the connection to the transmitter micro:bit.
    • If you accidentally connect the second browser to the micro:bit tilt controller, you will have to:
      • Unplug them both from USB, then plug them back in.
      • After that, retry connecting the micro:bit Python Editor in one browser to one micro:bit, and the micro:bit Python Editor in the other browser to the other micro:bit.
      • You will have to choose between micro:bits in the python.microbit.org wants to connect popup.

Example script: radio_tilt_receive_test

  • In the micro:bit Python Editor connected to the cyber:bot, set the project name to radio_tilt_receive_test.
  • Enter radio_tilt_receive_test.
  • 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_receive_test

from microbit import *
import radio

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

sleep(1000)

while True:

    packet = radio.receive()

    if packet:

        dictionary = eval(packet)

        x = dictionary.get('x')
        y = dictionary.get('y')
        needle = dictionary.get('needle')
        
        print("Receive:")
        print("x =", x, ", y =", y, ", needle =", needle)
        print()
        
        display.show(Image.ALL_CLOCKS[needle])
        
        sleep(500)

The goal is to be able to tilt the transmitting micro:bit, and verify matching data in the receive terminal, and on the receiver micro:bit’s LEDs.  So, you will be tilting the transmitter while monitoring the receiver.

  • In the browser with the micro:bit Python Editor that’s connected to the receiving cyber:bot, click Show serial.
  • Tilt the transmitter micro:bit in various directions.
  • Verify that the micro:bit on the receiving cyber:bot displays the direction you are tilting with its 5×5 LED matrix display.
  • Verify that the serial monitor connected to the cyber:bot displays the x, y, and needle measurements in the terminal.

  • If you are just here to make your tilt-controlled cyber:bot work, skip to Radio Tilt Controlled cyber:bot App.  Otherwise, keep going to the next page to see how these test scripts work.

 


Printer-friendly version
Radio-Transmit Tilt
Prev
How the Tilt Radio Tests Work
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress