Ted's,
I'm a rooky at electronics, so what the other guys are suggesting is probably better, but here's how I use a CDS cell for detecting day and night on my circuit, and I think it would work here to, as long as no outside light can get to it. The part number is from digikey: PDV-P9203-ND The specs say:
Rise Time (Typ) 70ms
Fall Time (Typ) 15ms
I don't know, but I'll bet that would work for ya.
I connect one side directly to the +5V of my board, and the other side to a pin on the PIC. This is the code that I use, and it has worked really well. What I have found using this code, is that it works with pretty much any CDS cell. I had 5 different ones, and they all detected dark at about the same light level with this code. For really good measurement of changes in light level, I'm sure there are better, and more complicated, ways to do this, but this is great for detecting day or night (or light on/off). After reading how RC time works, I'm not real sure why the value of about 46 to 49 is consistently dark on all of the cells I tested, but hey it works.
DayNight VAR BYTE
DayOrNot VAR BIT
Low PORTB.5 'Pin Connected to CDS Cell
Pause 10
RCTime PORTB.5,0,DayNight 'Read rctime value into DayNight variable
If Daynight > 46 Then 'It's dark
DayOrNot = 0
Else 'It's Daylight
DayOrNot = 1
End If
Gary




Bookmarks