Hi,
> what if I wanted to run a different command to just turning on the LED
Don't understand this one, sorry...
> what about if I wanted to start the LED flashing upon button tap?
Well, yes. But as soon as you mention blinking it starts to get a Little bit more complicated. Why?
Because then you need delays in there, during which (if using PAUSE) the button won't be polled so it'll feel unresponsive. Of course there are ways around this but the correct one depends on what you want to do after we get that LED to blink....
Try this (I haven't, hope it works....):/Henrik.Code:LEDState VAR BYTE Time VAR WORD LED_OFF CON 0 LED_ON CON 1 LED_FLASH CON 2 Rate CON 250 ' Time between LED toggles when blinking Main: IF Switch = 1 THEN ' If the button is pressed... LEDState = LEDState + 1 IF LEDState = 3 THEN LEDState = 0 Pause 20 ' Then we wait for contact bounce on make to die, may need tweaking WHILE Switch = 1 : WEND ' Then we wait for the user to actually release the button Pause 20 ' Finally we wait for contact bounce on release to die, may need tweaking ENDIF IF (LEDState = LED_OFF) or (LEDState = LED_ON) THEN LED = LEDState ' Turn LED on or off, solid. ENDIF IF LEDState = LED_FLASH THEN Time = Time + 1 IF Time = Rate THEN TOGGLE LED Time = 0 ENDIF PAUSEUS 1000 ENDIF Goto Main




Bookmarks