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 Basics

Cybersecurity: Radio Basics

How Texting Works

The main loop in each program repeatedly and rapidly checks to find out if any characters were typed into the keyboard or received by the radio.  If uart.any() is zero, meaning nothing was typed into the terminal, the script moves on to check for messages from the radio.  If that’s none too, the while True loop just repeats, rapidly, without doing anything else.  

while True:
    if uart.any():
        tx = input("Send: ")
        radio.send(tx)
    message = radio.receive()
    if message is not None:
        print("Receive: ", message)

If uart.any() is something other than zero, meaning you have typed characters into the terminal, tx = input(“Send: “) makes the Send: prompt appear.  It then stores the characters you type into the tx variable as a string, up until you press the Enter key.  Then, radio.send(tx) transmits that string over the radio for another micro:bit to receive and forward to its terminal.

Remember that message = radio.receive() either stores a string or None in message.  If message has a string, then print(“Receive: “, message) displays it.


Did You Know?

UART — it stands for universal asynchronous receiver transmitter. UART communication is one of several common communication protocols that devices use to exchange data.

Buffers — Incoming messages to the UART are stored in a special string called a buffer that is set aside for keeping characters until you need them. The radio object also has a buffer.

TX & RX — The abbreviation tx is short for transmit.  If you see tx in scripts, you might also see rx, which is shorthand for receive.  For example, the message variable could be named rx instead.

Dropped Packets — In its current form, the application drops packets sometimes.  In other words, not every message you type will be received and displayed by the other micro:bit.  


 


Printer-friendly version
Bidirectional Texts
Prev

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress