Re: Led blink and interrupt

Originally Posted by
critix
Hi. Can you help me with this: I have a 12F675. Pin 0 and 1 are connected LEDs. On pin 2 and 3 are related buttons. - If I press the button 2 LED 0 blink 10 times at 1s. If, as do those LED 0 blink, if I press the button 3, I would like to stop LED 0, and wait for pressing button again. - If I press the button 3 LED 1 blink 10 times at 1s. If, as do those LED 1 blink, if I press the button 2, I would like to stop LED 1, and wait for pressing button again. Can you help me with some examples? Thanks in advance. Cristi
Hi Christi, Sounds like you are building an auto signal, did that myself. set up a for next counter to blink your Leds. The interrupt should direct your counter variable to exit the loop by fulfilling the expected value I E 10 in this example, or without using an interrupt you could poll the input pins for change. UNTESTED example:
Code:
i var byte
main:
if gpio.2 = 1 then gosub blink1
if gpio.3 = 1 then gosub blink2
goto main
'subroutines below
blink1:
pause 300 ' debounce time
for i = 0 to 9 'set up blinker
if gpio.2=1 then i = 10 'check for reset
if gpio.3=1 then i = 10
gpio.0 = 1 'turn on
pause 1000
gpio.0 = 0 'turn off
pause 1000
next i 'next count
gpio0=0 'make sure light off b4 exit
return
blink2:
pause 300 'debounce time
for i = 0 to 9
if gpio.2=1 then i = 10 'check for cancel
if gpio.3=1 then i = 10 'check other switch
gpio.1 = 1
pause 1000
gpio.1 = 0
pause 1000
next i
gpio.1=0 'make sure light off b4 exit
return ' to main loop
Last edited by Archangel; - 24th April 2012 at 11:41.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks