Shop OBEX P1 Docs P2 Docs Learn Events
One Switch and Two Led's — Parallax Forums

One Switch and Two Led's

TrickyTwoTrickyTwo Posts: 1
edited 2009-12-24 06:21 in Propeller 1
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)




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




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



Thank You

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-24 06:21
    How about figuring out the rules for this yourself? You can set an I/O pin to logic high (OUTA[noparse][[/noparse]Pn] := 1) or to logic low (OUTA[noparse][[/noparse]Pn] := 0). You can check the value of an I/O pin (INA[noparse][[/noparse]Pn] == 0) or (INA[noparse][[/noparse]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?
Sign In or Register to comment.