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

Visible Light Navigation for the cyber:bot

Test the Light Sensor Eyes

Example script: left_light_sensor

The script left_light_sensor charges the capacitor in the P8 circuit, measures the time it takes for the capacitor to discharge, and displays that value on the micro:bit module’s LED matrix.  Remember, with this circuit and script, lower numbers mean brighter light now!

  • Set the cyber:bot board’s PWR switch to 0.
  • Use the micro:bit Python Editor to open a previous cyber:bot project, like halt_under_shadow or cyberbot-template-with-blink.
  • Set the project’s name to left_light_sensor, update the script so that it matches the one below, and then click Save.
  • Click Send to micro:bit.  
# left_light_sensor

from cyberbot import *

while True:                       
    bot(8).write_digital(1)        
    qt_left = bot(8).rc_time(1)      
    
    display.scroll(str(qt_left))           
    sleep(500)   
  • Set the cyber:bot board’s PWR switch to position 1.
  • Point your cyber:bot towards the room’s light source, then shade the left phototransistor with your hand. 
  • Watch the micro:bit module’s display. It should be showing numbers between 0 and 77,000, with brighter light making for smaller numbers.  If not, check wiring and rerun the program.

Your Turn

The other phototransistor circuit on the right side of the robot also needs testing!

  • Change the project name from left_light_sensor as right_light_sensor.
  • Change the both of the bot(8) commands to bot(6).
  • Change the variable qt_left to qt_right in both places.
  • Click the Save button to save your changes.
  • Click Send to micro:bit.
  • Set the cyber:bot board’s PWR switch to position 1.
  • Make sure the micro:bit module’s display is changing its numbers as you point the right phototransistor towards the light source and then shade it with your hand.

These steps are important!  
Your circuits and code must pass these tests before continuing.  The rest of the examples in this chapter rely on both light sensors working correctly.

 


Printer-friendly version
Build the Light Sensor Eyes
Prev
RC-time and Voltage Decay
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress