PDA

View Full Version : Led blink and interrupt



critix
- 24th April 2012, 09:45
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

Archangel
- 24th April 2012, 11:20
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:


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

critix
- 24th April 2012, 11:31
Yes, I want to build an auto signal. You did one?
Can you give me your code?
Thanks