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
  • Control your cyber:bot with an Infrared TV Remote

Control your cyber:bot with an Infrared TV Remote

Drive your cyber:bot with the Remote

With the next program, use buttons 1-9 to drive the robot in different directions.  Once you press a button, your robot will drive in that direction until you choose another direction. Press 5 to make it stop.

  • Change the project’s name from ir_remote_test to ir_remote_control. 
  • Enter the script below, and then click Save.
  • Click Send to micro:bit.  
  • Unplug the USB cable from the cyber:bot.
  • Set the cyber:bot on the floor, and set the cyber:bot board’s PWR switch to 2.
  • Point the remote at the IR receiver on the board, and press numbers on the remote to make it drive. Press 5 to make it stop.
# ir_remote_control

from cyberbot import *
from tv_remote import *

wL = 0
wR = 0
img = Image.HAPPY

bot(22).tone(2000, 300)

while True:
    num = ir(10).remote()

    if num == 1:
        wL = 0
        wR = -75
        img = Image.ARROW_SE
    elif num == 2:
        wL = 75
        wR = -75
        img = Image.ARROW_S
    elif num == 3:
        wL=75
        wR=0
        img=Image.ARROW_SW
    elif num == 4:
        wL=-75
        wR=-75
        img=Image.ARROW_E
    elif num == 5:
        wL=0
        wR=0
        img=Image.HAPPY
    elif num == 6:
        wL=75
        wR=75
        img=Image.ARROW_W
    elif num == 7:
        wL=0
        wR=75
        img=Image.ARROW_NE
    elif num == 8:
        wL=-75
        wR=75
        img=Image.ARROW_N
    elif num == 9:
        wL=-75
        wR=0
        img=Image.ARROW_NW

    display.show(img)
    bot(18).servo_speed(wL)
    bot(19).servo_speed(wR)

 


Printer-friendly version
Test the IR Receiver Circuit
Prev
How the IR Remote Control Code 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