I'm using a 12F675 with 4mhz ceramic osc to control my homebuilt gate opener. I'm activating it with a wireless digital remote unit that has it's own relay, when signal is rx'd the relay simply closes and provides a high (+5v) to GPIO.3. This pin is also held low via a 10k resistor. This then toggles GPIO.0 which I have 2 status LED's hooked cathode to cathode.

The problem is, all will work fine for days then suddenly it will start "toggling". That is, the gate will open, stop for a while then close over and over then simply go back to normal. Very randomly ! My PS is simply a sealed lead acid 12V battery with nothing else connected as of now. I thought the problem might be RF activating the wireless relay so i put a 3 second routine in, same problem so I disconnected the remote completely from the circuit and it happened again today. I currently have the board on my workbench powered by the same battery and it's stable for now, of course.

So if you will please look at my code and see if it's something in there ? I know I'm still not real good at PBP but I've actually had a lot of success with many other projects using PBP and I love it.

Thanks very much for your time,

Sam

Code:
'****************************************************************
'*  Name    : This is the one used for the gate opener !!!      *
'*  Author  : SD                                                *
'*  Notice  : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 3/15/2016                                         *
'*  Version : 1.0                                               *
'*  Notes   :  THIS WORKS MUST HOLD DOWN FOR 3 SECONDS TO TOGGLE*
'*          :                                                   *
'****************************************************************
CMCON=%00000111
ANSEL=%00000000


@ DEVICE pic12F675, XT_OSC
_NOCLKOUT
@ DEVICE pic12F675, WDT_ON
@ DEVICE pic12F675, PWRT_ON
@ DEVICE pic12F675, MCLR_OFF
@ DEVICE pic12F675, BOD_ON

DEFINE OSC 4
INCLUDE "modedefs.bas"

btn var gpio.3
LoopTime var word

'low gpio.0
low gpio.1
low gpio.2
'high gpio.3
low gpio.4
low gpio.5

InputButton:
pause 20
if btn = 1 then Check4Button
goto InputButton

Check4Button:
for LoopTime = 0 to 3000     'Set time button must be down before toggle happens. 50= 50ms, 3000= 3 sec
pause 1
'if btn = 0 then close               'Do not use this line for gate opener
next LoopTime
if btn = 1 then tgl
goto InputButton

tgl:
toggle gpio.0
if gpio.0=1 then 
gosub close
endif

if gpio.0=0 then
gosub open
endif
goto InputButton





open
pause 1000       'Orange LED on
high gpio.1
pause 18500
low gpio.1
goto InputButton

close
pause 1000     'Blue LED on
high gpio.2
pause 19000
low gpio.2
goto InputButton