Reading a push button switch with the Parallax Propeller

Propeller Push Button CircuitTo accurately detect the push of a button, you must pull the Prop pin to ground ("pulling low") so that when you push the button the pin can detect that it was pulled high. The 10K ohm resistor is used to pull the pin low because it's low enough to pull the pin low and high enough to prevent too much current to flow from the short circuiting of pushing the button. With the 100ohm resistor protecting the Propeller pin, most of the voltage will flow in that direction thus signaling the pin that it's high.

Propeller pins are inputs by default, so there's no real need to set it with dira[18] := 0

The code for reading the pin looks like this:


dira[18] := 0     ' again this is redundant really and not needed - good habit maybe?

if ina[18] == 1 then
' the button was pushed do something cool here
' do something here because of the users inability to push the button