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
  • LED Lights

LED Lights

How it Works

How the led_blink_2x Script Works

These statements repeat indefinitely inside the while True loop:

  • The pin13.write_digital(1) method call sets a high signal through P13, turning on the green light.  
  • The pin14.write_digital(1) call does the same thing but through P14, turning on the yellow light.
  • The sleep(500) call makes the script pause for 0.5 s.  The lights stay on during this time.
  • The pin13.write_digital(0) and pin14_write_digital(0) calls set P13 and P14 low, turning the LED lights off.
  • The sleep(500) call makes the script pause for another 0.5 s, during which time, the lights stay off.

Try This: On/Off Alternating

Changing from simultaneous to alternating blinks is pretty simple.  All you have to do is change the state argument in two of the pin14.write_digital calls.

  • Change the line 1 comment and the project name field to led_blink_2x_alternating.  
  • Change the first pin14.write_digital call’s state argument from 1 to 0.
  • Change the second pin14.write_digital call’s state argument from 0 to1.
  • Click Save and then click Send to micro:bit.
  • Verify that only one light is on at a time, and that they alternate.

 


Printer-friendly version
Script and Tests
Prev
Sequential Blinks
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress