Thanks everyone for your assistance. The problem end up being associated with the LDR. I have the output of the LDR circuit going to the comparator of the PIC. The result is then assigned to a variable and subsequent code is used to make decisions. Here is a simplified example of my original code- VL is the variable.
For I = 1 to 20
Pause 500
ADCIN 0, VL
If VL => 300 then
Light = 1
Indicator LED = 1
Endif
If VL =< 100 then
Light = 0
IndicatorLED = 0
Endif
Next I
My thinking was that I could bypass the threshold that exists in a LDR between light and dark by inserting a gap of 100 ( difference between 300 and 100) and a half second Pause in the For / Next loop. I used the For/Next loop count to 20 along with the Pause to ensue the light change was permanent and not from some errant source.
This did work but during the time VL hovered around the threshold zone (between 300 and 100) I start receiving unpredictable results. If at the end of the 20 count the threshold was still present the program became confused and would open the door halfway, stop, and crash.
So I changed the code to this:
For I = 1 to 20
Pause 500
ADCIN 0, VL
If VL => 300 then
Light = 1
Indicator LED = 1
Else
Light = 0
IndicatorLED = 0
Endif
Next I
This seems to work but only have one night of results but I'm optimistic.
skybox
Bookmarks