hi, the code works fine under slow speed, it will count up to 3 and go off the led for 1 s, then on back again.
Please see actual code.
Code:
DEFINE OSC 4
cnt VAR BYTE
delay var byte
boton VAR GPIO.2
mosfet VAR GPIO.1
' ANSEL = 0 '12F675 for test
CMCON = 7
OPTION_REG.7 = 0 'Pullups enabled
WPU = %00000100
cnt = 0
GPIO = %00000110 ' Nosurprise startup ...
TRISIO = %00000100
'******************************************************************************
Detect: 'Button presses W/Debounce
'
delay = 0
BUTTON Boton ,0,255,0,delay,1,pressed
' Slow Things down
GOTO Detect
'******************************************************************************
Pressed: ' Some > 10ms press detected
IF cnt <=1 Then 'tocount uptu 3, bigger values will add up.
cnt = cnt + 1
ELSE
cnt = 0
LOW mosfet
PAUSE 1000
high mosfet
ENDIF
WHILE !Boton : WEND ' Wait Boton release !!!
goto detect
END
I need much faster reading from the pic, other wise, it will count moreto go off, on breadboard, it may not even go on again.
For some oscure reason, my Pbasic compiler, does not like the configuration line you put, after the OSCAL SETTING, in line one.
So I have to set it manualy, using software configuration bit facility.
See my circuit, but, instead of 2 only one led, on GP1, and Push boton on GP2.
Best regards.
Thanks Acetronics.
Bookmarks