Turn digitaloutput to 1 when PWM value is 255

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.

Many Thanks!

What LED modual are you using?
Show us your sketch.

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);
}

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
}

When you do an analogue write with a value of 255 then the output is a logic one just the same as if you did a digital write.

So what ever your problem is then this is not the soloution anyway.

OP is controlling another pin, the PWM is not the sole driver. Could be faking an analog output, and 3.3V or 5V is not enough to achieve full off.

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.

Perhaps. Hard to say without seeing the design of that module.

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.

Il post a copy of my sketch so you can see.