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
  • Touch Navigation for the cyber:bot

Touch Navigation for the cyber:bot

Escaping Corners

When running roaming_with_whiskers, you may have seen your cyber:bot get stuck in a corner. Its left whisker touches a wall so it turns right, then its right whisker touches a wall so it turns left, over and over again, until you rescue your robot.

Track Input to Recognize Patterns

The next example project counts alternate whisker presses to determine if the cyber:bot is stuck in a corner. To do this, the project has to remember what state each whisker was in during the previous contact. If they are opposite, then one is added to a counter. If that counter goes over a threshold that you set, then it is time to turn around out of the corner (and reset that counter). In this way, your cyber:bot “remembers its experience” to be “aware of its predicament” so it can respond appropriately; a primitive example of artificial intelligence.

This project relies on nested if…else statements. The project checks for one condition, then if that condition is true, it checks for another one within the first condition. The project escaping_corners actually uses three if statements nested together.

Example project: Escaping Corners

  • Put the cyber:bot board’s power switch in position 0 or 1.
  • Enter and flash escaping_corners.
  • Put the cyber:bot on the floor in a corner and set the switch to position 2.
  • Using obstacles or your hands, alternate right and left whisker presses to simulate being stuck in a corner. After four or five bounces off of alternate walls, your cyber:bot should turn around and leave the corner.


Printer-friendly version

Leave a Comment Cancel reply

How the Navigating by Touch Code Works
Prev
How Escaping Corners 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