Button command Help!
Magicalman
Posts: 3
Hello I am very, very new to the Propeller and apologize for such a basic question however i could sure use some direction, I have used pbasic for a number of years but just cant seem to figure this out in Spin
All i would like to do is be able to alternately turn on and off say 8 Led's on p1 through p9 each time i press a button on p0, it seems simple?
I am able to turn the leds on and off using the outa command but just cant wrap my head around how the button loop works in Spin. once again i apologize for the trivial question but could really use some advice !
All i would like to do is be able to alternately turn on and off say 8 Led's on p1 through p9 each time i press a button on p0, it seems simple?
I am able to turn the leds on and off using the outa command but just cant wrap my head around how the button loop works in Spin. once again i apologize for the trivial question but could really use some advice !
Comments
Depending of how you have connected your button you may need to swap the states for pressed (1) and released (0). To make a running code out of that, you need to add a PUB and declare the select variable (as long).
Andy
This code is currently deployed in the Buzz Lightyear hand-stamper that will start showing up in Disney parks.
Again, this is for a single input and will not return until the condition is met. The fun is in the last line of the loop: the debounce timing is incremented and then multiplied by the state of the pin. If the pin bounces open (0) then the timer is reset.
Thanks for share this