walumbe
Junior Member level 2
- Joined
- Oct 15, 2013
- Messages
- 20
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 174
I'm new to the PIC world and would like some help with my code.
In using a PIC12F683 (MikroBasic code) to TURN ON an output (GP2) when two inputs (GP0 and GP1) are both high. If both inputs are HIGH, the output GP2 will go HIGH and remain in that state for 2 minutes then TURN OFF. I am looking for pointers on how to RESET the 2 min timer (delay) to restart if GPO and GP1 go HIGH again before the 2 minutes are done. Currently my program runs through the 2 minutes and turns off before it can be re-triggered. GPO and GP1 inputs are those of a dark detector and a vibration sensor.
main:
ANSEL = 0
ADCON0 = 0
CMCON0 = 7
TRISIO = %00000011 'Set GP0 and GP1 as inputs , GP2 as output
GPIO.B0 = 0 'Initial GP0 value -> Dark Detector
GPIO.B1 = 0 'Initial GP1 value -> Vibration Sensor
GPIO.B2 = 0 'Initial GP2 value -> LED
while True 'Endless loop
if Button(GPIO, 0, 1, 1) then 'detect logical one on GP0
if Button(GPIO, 1, 5, 1) then 'detect logical one on GP1
GPIO.B2 = 1
Delay_ms(120000)
else
end if
GPIO.B2 = 0
end if
wend
end.
In using a PIC12F683 (MikroBasic code) to TURN ON an output (GP2) when two inputs (GP0 and GP1) are both high. If both inputs are HIGH, the output GP2 will go HIGH and remain in that state for 2 minutes then TURN OFF. I am looking for pointers on how to RESET the 2 min timer (delay) to restart if GPO and GP1 go HIGH again before the 2 minutes are done. Currently my program runs through the 2 minutes and turns off before it can be re-triggered. GPO and GP1 inputs are those of a dark detector and a vibration sensor.
main:
ANSEL = 0
ADCON0 = 0
CMCON0 = 7
TRISIO = %00000011 'Set GP0 and GP1 as inputs , GP2 as output
GPIO.B0 = 0 'Initial GP0 value -> Dark Detector
GPIO.B1 = 0 'Initial GP1 value -> Vibration Sensor
GPIO.B2 = 0 'Initial GP2 value -> LED
while True 'Endless loop
if Button(GPIO, 0, 1, 1) then 'detect logical one on GP0
if Button(GPIO, 1, 5, 1) then 'detect logical one on GP1
GPIO.B2 = 1
Delay_ms(120000)
else
end if
GPIO.B2 = 0
end if
wend
end.