Skip to content
Parallax Learn (Stage)

Parallax Learn (Stage)

This is the staging site. Please see https://learn.parallax.com for the official site.

  • 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 Tutorial Series
          • Cybersecurity: Radio Data tutorialCybersecurity Tutorial Series
          • cyber:bot Tutorial Series
          • Boe-Bot Tutorial SeriesBoe-Bot Tutorial Series
          • Arduino Shield-Bot Tutorial Series
          • ActivityBot with C TutorialsActivityBot with C Tutorials
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot with BlocklyProp Tutorial Series
          • Scribbler 3 Tutorial SeriesScribbler 3 Tutorial Series
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education Tutorial Series
          • Propeller C-Language BasicsPropeller C Basics and Projects
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit C Tutorial Series
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit BlocklyProp Tutorials
          • Badge WX Tutorial SeriesBadge WX Tutorial Series
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics and Projects
          • 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
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Circuit Practice with BlocklyProp

Circuit Practice with BlocklyProp

Blink a Light

The Propeller microcontroller has 32 input/output pins, or I/O pins, labeled P0 through P31.  The Propeller can interact with other circuits connected to these I/O pins, through programs that use these labels. A Propeller I/O pin can do three things:

  • Connect a circuit to 3.3 V supply, as shown below left. This is known as setting the pin to “output high.”
  • Connect a circuit to 0 V, that is, ground, as shown below right. This is setting the pin to “output low.”
  • Just monitor a circuit to see if it is already connected to 0 V, or 3.3 V.  This is called setting the pin to an “input.”

We’ll experiment with the “O” (output) feature of an I/O pin by programming the Propeller to turn a light on and off.  The light circuit, which includes a small LED and resistor, is already built into the Propeller Activity Board (original or WX) or the Propeller FLiP module.  That built-in circuit is connected to I/O P26, so our code will use P26 instead of P14 (like in the picture above.) 

Circuit

  • Locate the small LED part or aperture on your board. It’s just above the P26 label.

Note: if you are using a different Propeller board that does not have a built-in lights connected to P26 and P27, build the equivalent circuit using the schematic.

Test Code

In BlocklyProp, you can turn an LED on or off with a single block: the Pin states block make PIN (dropdown).

  • Open BlocklyProp Solo, connect your board to your computer, and make sure the BlocklyProp Launcher is running.
  • Start a new project for your board, and build the project shown above in the workspace. Hint: The repeat and pause blocks are in the Control menu, and the make PIN block is in the Pin states section.
  • Save your project, and click the Run Once button.
  • Verify that the P26 light turns on for half a second, then off for half a second, over and over again.

How it Works

The first make PIN block sets the Propeller chip’s P26 I/O pin to output-high, which connects the pin to its 3.3 V supply.  The pin applies 3.3 V of electrical pressure to the LED circuit, causing electric current to pass through it and the light to turn on.  After that, pause(500) makes the program do nothing for 500 ms, which keeps the light on for half of a second. 

Next, low(26) sets P26 to output-low, which connects the pin to its 0 V ground supply voltage instead.  This takes away the electrical pressure, so the current stops flowing through the circuit and the light turns off.  Another pause(500) makes the light stay off for half of a second.


Did You Know?

The picture below is called a timing diagram. It is a graph with voltage on the vertical axis, and time on the horizontal axis. Timing diagrams are often used to describe the electrical interaction between microcontrollers and circuits or other devices. This timing diagram shows the output of I/O pin P26 from the test code above.


Try This

You can make the light blink faster or slower by changing the value in the pause block.  You can also make the on-time different from the off-time by using different values in the two pause blocks.

  • Modify the program so the LED blinks twice as fast, as shown by the example code and timing diagram below.  What happened to the pause values?

  • Modify the program so the LED is on three times as long as it is off. What happened to the pause values?

Your Turn

Try controlling the P27 light along with the P26 light, according to the timing diagrams below.

  • Add blocks to your program so that the P27 light turns on and off at about the same time as the P26 light.

  • Modify the program so that whenever the P26 light is on, the P27 light is off, and vice versa.


Printer-friendly version
Check Pushbuttons
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn (Stage) • Built with GeneratePress