Many items you use every day have pushbuttons. Cell phones, microwave ovens, TV remotes, and computer keyboards might all have pushbuttons. Can you think of others?
Let's use a common pushbutton circuit and build a program for monitoring it with your microcontroller. Then, let's use a pushbutton's state to control LED circuits. LEDs are just one example of a device you can turn on and off with a microcontroller. Your invention might instead use pushbuttons to control circuits for motors, heating elements, or other devices.
A pushbutton is a device that makes an electrical connection between two of its terminal leads when its button is pressed. When the button is released into its normally-open state, the electrical connection is broken and no current flows through the device. Here is the schematic symbol:
...and here is a drawing that resembles a breadboard-friendly pushbutton:
The Propeller I/O pins connected to pushbutton circuits must be set to inputs. If the pushbutton is pressed, the circuit applies 3.3 V to the I/O pin through the pushbutton, and a small amount of current also passes through the 10 kΩ resistor to ground. When the pushbutton is not pressed, the connection to the 3.3 V supply is broken, and so the circuit applies GND (0 V) to the I/O pin.
This circuit uses your board's built-in P26 and P27 LEDs, along with two pushbutton circuits you will build onto your breadboard. You may use either 220 ohm or 100 ohm resistors to connect the pushbutton circuits to the Propeller I/O pins. However, you must use 10 k-ohm resistors to connect the circuits to ground.
This test code will display the state of the button connected to P3 in the BlocklyProp Terminal. The Terminal displays 1 if the button is pressed, or 0 if it is not pressed.
After a Terminal clear screen block, the rest of the project is in a repeat forever loop. First, a Terminal print text block supplies a useful label "P3 button = " for our data. Next comes a Terminal print number block. Inside it, the check PIN 3 block sets the P3 I/O pin to input. If the Propeller senses 0 V on P3 while the button is not pressed, the block provides a 0, and that gets printed in the Terminal. If the Propeller senses 3.3 V on P3, the block provides a 1, and that gets printed instead. A pause (ms) 200 block slows down the loop just enough to display properly before repeating.
Now it is time to control an LED with a pushbutton! Remember if...do block from from the BlocklyProp Making Decisions [1] activity? It comes in very handy for this.
Let's get you modify your program to make the LED connected to P27 blink when the button connected to P4 is pressed?
Links
[1] http://learn.parallax.com/tutorials/language/blocklyprop/simple-blocklyprop-programs/making-decisions