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:
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.)
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.
In BlocklyProp, you can turn an LED on or off with a single block: the Pin states block make PIN (dropdown).
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.
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.
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.
Try controlling the P27 light along with the P26 light, according to the timing diagrams below.