Hi guys, I'm looking for some advice on a sketch of mine. I am using a PWM output to control a light from a web based GUI.
Due to the design of the light module, when PWM is set to 255 (pwm max value, minimum brightness) the LED module will still be dimmed to about 20%, still drawing significant power. The only way to completely turn off the module is by a separate digitalWrite command to a separate digital pin connected to the Light's PSU on/off function.
I could correct this issue externally by sending a separate write command, but it would create more complexity, I would much rather correct it in the sketch!
Where would I start in creating a rule that will look for the the PWM output match at 255 and then perform a separate 1/0 write to a digital pin.
CrossRoads:
Huh? If you do this
analogWrite (A0, 255);
then you know what you wrote.
Why not just follow it up with the digitalWrite?
Or look for the value to be sent in somehow.
analogWrite (analogPinX, incomingValue);
if (incomingValue == 255){
digitalWrite (digitalPinX, HIGH); //Or LOW, depending on the LED module you used
} else {
digitalWrite (digitalPinX, LOW); //Or HIGH, depending on the LED module you used
}
Due to the design of the light module, when PWM is set to 255 (pwm max value, minimum brightness) the LED module will still be dimmed to about 20%, still drawing significant power.
The design of this is wrong, that is what needs correcting.
Grumpy_Mike:
Yes but it is this bit that is wrong.
Due to the design of the light module, when PWM is set to 255 (pwm max value, minimum brightness) the LED module will still be dimmed to about 20%, still drawing significant power.
The design of this is wrong, that is what needs correcting.
Sometimes units have a "fail safe" configuration. If the MCU fails (No outputs) that the unit switches to max. This sounds like that.
If the circuit used is a common collector with the PWM on base, this is the expected result.
But as CrossRoads mentioned, it purely speculation until we have the specs of the device...
Its a custom PSU with two LG 50W LED module's. The maximum PWM input to the PSU is 3.3v which will dim the lights to around 20%. The manufacturer of the PSU previously used the PSU in conjunction with a propitiatory powerline/grid style communication protocol. I am using a miniaturized wireless arduino in conjunction with a raspberry pi and basic web GUI written in perl to make it all work.