Ming thuang bing daaang zing YIIIHHHAAA 
Code:
' PIC12f629
' Push-button attach to GPIO<3:0> between i/o and VCC
'
' it assume you'd previously disable all analog stuff and MCLR pin
'
aPushButton var byte
PushButton var byte
Delay var Word
Start:
clear
apushbutton=GPIO & $0F ' read push-button
' keep only GPIO<3:0> bits
'
if apushbutton=0 then start ' no push button pressed, sit and spin
pushbutton=apushbutton
while (apushbutton!=0)
apushbutton=GPIO & $0F
pause 10
delay=delay+1
wend
pause 50 ' debounce delay
if DELAY<100 then ' if push button is press for less than 1 second
Select case PushButton
case 1
gosub PushButtonGPIO_0
case 2
gosub PushButtonGPIO_1
case 4
gosub PushButtonGPIO_2
case 8
gosub PushButtonGPIO_3
end select
endif
goto start
The above should work. There's probably tons of different way to do it but, this is the first interrupt/Assembler/InternalRegister adressing free comming example.
Last edited by mister_e; - 13th November 2005 at 20:22.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks