I want to fade a string of christmas leds and found this in a forum search
http://www.picaxeforum.co.uk/showthread.php?t=12471&highlight=rgb+fader&page=2
As the lights take 100mA or so, the sample circuit isn't meaty enough. So I hooked up an L293 driver chip, the 08m outputs taken to the driver inputs and the LED strings connected between the driver outputs and 0 volts. The pwm pin2 of the 08m is connected to both the enable pins of the L293.
Using this code, I was pleased with the initial results.
I then thought that a bit of flashing might be nice so I extracted part of the above code and added a flsh routine.
Doesn't work !!
If I just rem out the gosub fade, the LEDs flash. If I just rem out the gosub flash, the fade works.
If I leave them both in, the LEDs fade O.K. and then there is just a pause, with all LEDs off during the flash time.
Looks O.K. in the simulator.
Any ideas please.
Russ
http://www.picaxeforum.co.uk/showthread.php?t=12471&highlight=rgb+fader&page=2
As the lights take 100mA or so, the sample circuit isn't meaty enough. So I hooked up an L293 driver chip, the 08m outputs taken to the driver inputs and the LED strings connected between the driver outputs and 0 volts. The pwm pin2 of the 08m is connected to both the enable pins of the L293.
Using this code, I was pleased with the initial results.
Code:
'RGB LED Display
'PICAXE-08M
let dirs = %00010111 'set all used pins to outputs
main:
let pins = %00010000 '4
gosub fade
let pins = %00000001 '0
gosub fade
let pins = %00000010 '1
gosub fade
let pins = %00010001 '0,4
gosub fade
let pins = %00010010 '1,4
gosub fade
let pins = %00000011 '0,1
gosub fade
let pins = %00010011 '0,1,4
gosub fade
goto main
fade:
for w1 = 0 to 300
pwmout 2,99,w1
pause 20 'increasing brightness
next w1
pause 1000
for w1 = 300 to 0 step -1
pwmout 2,99,w1
pause 10 'decreasing brightness
next w1
pwmout 2,99,0
pause 1000
return
Code:
'RGB LED Display
'PICAXE-08M
let dirs = %00010111 'set all used pins to outputs
main:
let pins = %00010011 '4
gosub fade
gosub flash
goto main
fade:
for w1 = 0 to 300
pwmout 2,99,w1
pause 20 'increasing brightness
next w1
pause 1000
for w1 = 300 to 0 step -1
pwmout 2,99,w1
pause 10 'decreasing brightness
next w1
pause 1000
return
flash:
for b6=0 to 5
toggle 2
pause 500
next b6
return
Doesn't work !!
If I just rem out the gosub fade, the LEDs flash. If I just rem out the gosub flash, the fade works.
If I leave them both in, the LEDs fade O.K. and then there is just a pause, with all LEDs off during the flash time.
Looks O.K. in the simulator.
Any ideas please.
Russ