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 Tilt Controller Code

Load this application into the micro:bit (or cyber:bot) you want to use as your tilt controller.

The radio_tilt_controller script is just radio_tilt_controller_w_stop_range from Receiver Full Tilt Control & Stop Range.  It is repeated here for folks who skip the majority of the tutorial and go directly to running the application.

  • Make sure you are working in the browser with the micro:bit Python Editor that is connected to the radio tilt controller micro:bit.
  • Depending on the path you took to get here, your last micro:bit transmitter script might either be radio_tilt_transmit_test or radio_tilt_controller_w_stop_range.  If your most recent script is not already open, click Open to load it into the editor.
  • Set the project name to radio_tilt_controller.
  • Update the script to match the one shown 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.

Example script: radio_tilt_controller

# radio_tilt_controller

from microbit import *
import math
import radio

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

while True:
    x = accelerometer.get_x()
    y = accelerometer.get_y()

    angle = round( math.degrees( math.atan2(y, x) ) )
    needle = ( angle + 90 + 15 ) // 30

    if abs(y) > 80:
        display.show(Image.ALL_CLOCKS[needle])
    else:
        display.show(Image.DIAMOND_SMALL)

    dictionary = { }
    dictionary['x'] = x
    dictionary['y'] = y
    dictionary['needle'] = needle

    packet = str(dictionary)
    radio.send(packet)

    sleep(50)
  • Set the Set the (receiver) tilt controlled cyber:bot’s PWR switch to 1.
  • Verify that both the tilt controller and tilt controlled cyber:bot LED displays show matching tilt control needles as you tilt the controller micro:bit in various directions.
  • Verify that the LED displays show the diamond when you hold the tilt controller level.
  • Disconnect the cyber:bot from USB and place it on the floor or in a designated navigation pen.
  • Set the (receiver) tilt controlled cyber:bot’s PWR switch to 2.
  • Have fun radio-tilt-controlling your cyber:bot!

Printer-friendly version
Radio Tilt Controlled cyber:bot Code
Prev

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress