#picaxe 14M2
#no_data
#terminal 19200
symbol switch1 = PinC.0
symbol switch2 = PinC.1
symbol switch3 = Pinc.2
symbol iFlag = b0
INIT:
setfreq M16
setint OR %00000111,%00000111
MAIN:
do
pause 1000 '// Waitng for switch press
loop
interrupt:
pause 10 [COLOR="#008000"] '// ~ 5ms to Debounce Switch (May need to adjust)
[/COLOR]
[COLOR="#008000"]'// switch should still be pressed[/COLOR]
if switch1 = 1 then : iFlag = 1
elseif switch2 = 1 then : iFlag = 2
elseif switch3 = 1 then : iFlag = 3
endif
do while pinc.0 = 1 or pinc.1 = 1 or pinc.2 = 1 [COLOR="#008000"] '// Wait for switch release[/COLOR]
loop
if iFlag = 1 then
sertxd ("Switch 1 Pressed",cr,lf)
else if iFlag = 2 then
sertxd ("Switch 2 Pressed",cr,lf)
else if iFlag = 3 then
sertxd ("Switch 3 Pressed",cr,lf)
endif
iFlag = 0 [COLOR="#008000"] ;// Clear the flag[/COLOR]
setint OR %00000111,%00000111
return