View Full Version : One Switch and Two Led's

12-24-2009, 12:59 PM
What I would like to know is, How do I program the Propeller Chip, I want to use one switch and two Led's. The switch will input on the Propeller chip, (P1). The Led's will be (P2 and P3). So if you hold the switch down. It will make the two Led's light up (P2 P3). But when you hit the switch on and off at A slow pace, it will make one of the Led's stay on (P2) and the other Led will stay off (P3). If you don't hit the switch both of the Led's, stay off.

________________Switch_____(1111111111111111111)__ ______________________________ (State of power to Led's and switch (Off=0) (On=1)
__State of Led's Led (P2)______(1111111111111111111)
_______________Led (P3)____(1111111111111111111)

_State of Led's Led (P2)_____(1111111111111111111)
______________Led (P3)____(0000000000000000000)

_State of Led's Led (P2)_____(0000000000000000000)
_____________Led (P3)_____(0000000000000000000)

Thank You

Mike Green
12-24-2009, 01:21 PM
How about figuring out the rules for this yourself? You can set an I/O pin to logic high (OUTA[Pn] := 1) or to logic low (OUTA[Pn] := 0). You can check the value of an I/O pin (INA[Pn] == 0) or (INA[Pn] == 1). You can delay for a time period (WAITCNT(CLKFREQ/100+CNT)) where CLKFREQ is the number of clock ticks in one second, so CLKFREQ/100 is 1/100th of a second.

From your description, you want to know whether the switch stays off for some time period or stays on for some time period or changes within some time period. How would you do that?