Daylight Sensor
Hi everyone
i've this circuit & the code below.
i want light sensor that can automatically adjust the light intensity based on the ambient lighting, which will turn down the lights if a significant amount of sunlight is entering the room, and turn up the lights when there is little sunlight entering the room.
please help me with the coding if u have any. Thanks.
' {$STAMP BS2}
' {$PBASIC 2.5}
LOOP
resut VAR Word
HIGH 15
PAUSE 1
RCTIME 15, 1, result
DEBUG ? result
IF resut > 40 THEN turn ON
LOW 00
GOTO LOOP
turn ON:
HIGH 00
GOTO LOOP
i've this circuit & the code below.
i want light sensor that can automatically adjust the light intensity based on the ambient lighting, which will turn down the lights if a significant amount of sunlight is entering the room, and turn up the lights when there is little sunlight entering the room.
please help me with the coding if u have any. Thanks.
' {$STAMP BS2}
' {$PBASIC 2.5}
LOOP
resut VAR Word
HIGH 15
PAUSE 1
RCTIME 15, 1, result
DEBUG ? result
IF resut > 40 THEN turn ON
LOW 00
GOTO LOOP
turn ON:
HIGH 00
GOTO LOOP
![BasicStamp.png](https://forums.parallax.com/uploads/attachments/67362/91863.png)
Comments
However, if your CDS were connected to the pin used by the RCTIME, and the transistor were connected to pin 0 you should be able to get it to work.
Obviously, you'll adjust the value that triggers the turn ON: to an appropriate level based on your tests. Also, the variable in the IF statement must be spelled the same as the one on the RCTIME statement and the VAR declaration. Or, vice versa.
No guarantee that this code works, but something like this:
the LED light up but photoresistor has no afffect on the circuit.
how do i make the LED to adjust light intensity base on the ambient light level falling on the photoresistor?
thanks.
' {$STAMP BS2}
' {$PBASIC 2.5}
Result VAR Word ' Result doesnt need to be created multiple times
Main:
HIGH 15
PAUSE 1
RCTIME 15, 1, Result
DEBUG HOME, Result
IF (result > 40) THEN
GOTO TurnON
ELSEIF (result <= 40) THEN
LOW 0
GOTO Main
ENDIF
TurnOn:
HIGH 0
GOTO Main
I tested it, it works.
Btw, other than FREQOUT and the digital variable resistor, I don't see a way to to adjust the LED intensity.
the LED does light up but the LED doesn't seem to change brightness.
do i need to add anymore components or change the circuit?
pls help..