Trouble with turning off PWM on RGB LED

mccheesy

Member
I'm using a common-anode RGB LED with each leg (besides power, of course) to a separate PWM channel (PICAXE 20M2), and each leg has its own proper resistor value. Link to the LED Datasheet

Issuing the initial "pwmout" commands result in the desired brightness of each internal LED, but where the issue comes in trying to turn off any color after that first pwmout.

Here's a simple test program, using only a single LED as a test:
Code:
init:
symbol RED_LED = c.3
main:
pwmout pwmdiv4, RED_LED, 249, 599
wait 1
pwmout RED_LED, OFF
wait 1
goto main
If I am to understand the pwmout command correctly, to end a signal I use a pwmout command, the desired pin, and then "OFF"

Instead of turning off, what happens is the LED actually gets brighter when the "OFF" code is issued.

This is horribly frustrating and honestly quite confusing, especially since it's with something that seemingly should be quite simple.
 

AllyCat

Senior Member
Hi,
Issuing the initial "pwmout" commands result in the desired brightness of each internal LED,
Are you sure about that, I would expect the brightness to Reduce as you Increase the PWM value ?

If you're using a Common Anode (and thus driving the Cathode) then pulling down the PICaxe output voltage will increase the brightness. Thus to turn the LED off, you need to increase the PWM output to maximum and/or to switch the Output back to a "High" or Floating (Input command) level. Or drive the LED (Cathode) via an inverting transistor or FET.

So a simple High RED_LED (even outside the loop) might fix the problem.

Cheers, Alan.
 

mccheesy

Member
Hi,

Are you sure about that, I would expect the brightness to Reduce as you Increase the PWM value ?

If you're using a Common Anode (and thus driving the Cathode) then pulling down the PICaxe output voltage will increase the brightness. Thus to turn the LED off, you need to increase the PWM output to maximum and/or to switch the Output back to a "High" or Floating (Input command) level. Or drive the LED (Cathode) via an inverting transistor or FET.

So a simple High RED_LED (even outside the loop) might fix the problem.

Cheers, Alan.
That worked a charm, thank you very much!
I should have known that I'm sinking on the PWM so I should use the values the other way around.
 
Top