Hello
I am designing a light feedback system where in bright light the output light is off and in dark light the output light is on however the user will be able to set the brightness at any point so for example when its dark and the user has set the intensity the same as a normal dimmer control to half the output light will be half lit. then when it brightens up in the day this light dims until it is no longer required or increased so it comes on again.
the first problem is with the 100k potentiometer. i have it on leg 3 of my 14m (readadc 4). my code is as follows:
The parts in red are the parts i have added to try and make the LED turn off when the potentiometer is at its lowest point. At the moment if i turn the circuit on with the potentiometer off the LED is off but as soon as you turn it enough for it to light up it will not turn off again unless the circuit is turned off and on again.
I can't seem to fix this. I have checked the voltage from the potentiometer and when its turn one way I get 0 volts (off) and when the other way I get 4.7 I think or something close enough to 5 anyway. So I know its the programming.
I have just tested it by pwmout 2,99,b0 which is the potentiometer input and it turns off and gos to full brightness.
So can anyone see a better or more accurate way to compare the LDR and Potentiometer and output the required light level because it must be that. Is that right?
Thanks
SKl BOI
I am designing a light feedback system where in bright light the output light is off and in dark light the output light is on however the user will be able to set the brightness at any point so for example when its dark and the user has set the intensity the same as a normal dimmer control to half the output light will be half lit. then when it brightens up in the day this light dims until it is no longer required or increased so it comes on again.
the first problem is with the 100k potentiometer. i have it on leg 3 of my 14m (readadc 4). my code is as follows:
Code:
Main:
readadc10 0,b1 `LDR
readadc 4,b0 'potentiometer
[COLOR="Red"]if b0 <=50 then
goto Main
Endif
let b0 = 0
readadc 4,b0 'potentiometer[/COLOR]
let b2 = b1-32767
let b3 = b2+b0 / 2
pwmout 2,99,b3
[COLOR="red"]let b0 = 0[/COLOR]
goto main
I can't seem to fix this. I have checked the voltage from the potentiometer and when its turn one way I get 0 volts (off) and when the other way I get 4.7 I think or something close enough to 5 anyway. So I know its the programming.
I have just tested it by pwmout 2,99,b0 which is the potentiometer input and it turns off and gos to full brightness.
So can anyone see a better or more accurate way to compare the LDR and Potentiometer and output the required light level because it must be that. Is that right?
Thanks
SKl BOI
Last edited: