I'm trying to get my pic16f690 to count every time a switch is pressed until it reaches a certain number. I've written a simple test program but it doesn´t work...Somehow the switch is being ignored, the if statement gets executed everytime. switch or no switch. what am i doing wrong?(I´m using the low pin count demo board)TRISA = %00100000
TRISC.0 = 0
TRISC.1 = 0
led VAR PORTC.0
led2 VAR PORTC.1
butt1 VAR PORTA.5
counter VAR word
bcounter VAR word
counter = 0
bcounter = 0
'************************************************* ****************
loop:
high led2
pause 100
low led2
if butt1 = 0 then
high led
pause 100
low led
counter = counter + 1
endIF
if counter>5 then blink
goto loop
'************************************************* ****************
blink:
bcounter = bcounter + 1
high led
pause 500
low led
PAuse 500
if bcounter<5 then goto blink
counter = 0
goto loop
end
Bookmarks