Leds flicker

djmikeys

New Member
Hi,

I have created a circuit that reacts to light. When the light levels increase a LED dims and another set of LEDs increase in brigtness. One set of LEDs are Luxeon stars with their specific driver. The other is a set of LEDs that I bought seperatly, a plant grow, which I have hacked into.

I have got the circuit almost running the way I want it to. The only problem is that when it runs the Leds will sometimes flicker to the top brightness just for a split second. Does anyone know of a way of smoothing this out?

Here is my code and circuit diagram:

CODE....................................................

main:

readadc 1, b1 'reading what the light levels are
debug b1 ' show the value for the light level on the screen

'LED
w2 = 255 - b1
if b1 => 247 then goto off2 'The equation of a straight line, how does the led react to the light sensor value
pwmout 2,255,w2
'controlling the power coming from pin2 (if w2=0 then its off, if w2=255 then its full on)
'PLANT GROW
w1 = b1*3-531 'The equation of a straight line, how does the grow lights react to the light sensor value
if b1 =<178 then goto off1 ' if it is dark goto 'off1'
pwmout 1,255,w1
'controlling the power coming from pin1 (if w1=0 its off, if w1=255 its full on)
goto main

off1:
low portc 1 'Turn pwm1 off
goto main

off2:
low portc 2
goto main

END OF CODE................................................

and the diagram..................
 

Attachments

djmikeys

New Member
Sorry that looks confusing, here is the code again:


main:

readadc 1, b1
debug b1

'LED
w2 = 255 - b1
if b1 => 247 then goto off2
pwmout 2,255,w2

'PLANT GROW
w1 = b1*3-531
if b1 =<178 then goto off1
pwmout 1,255,w1

goto main

off1:
low portc 1
goto main

off2:
low portc 2
goto main
 

eclectic

Moderator
First quick thought.

Manual 2, page 117

It looks like you should use

pwmout 1 off

pwmout 2 off

e

Add Second thought. Have a look at the PWMout DUTY command.
 
Last edited:
Top