HLG Driver PWM

Hello, good evening to all

I plan to control a driver meanwell HLG by PWM

I did some research (thanks Wawa ^^) and I made this little schematic

It should work. The problem is that the PWM signal will be inverted (PWM has 255, driver has 0%, PWM has 0 driver at 100%)
I wish I could put the PWM 255 = 100%

Could this circuit work?

I know we can solve it by software but I would like to do it by hardware way.

Thank you ^^!

Second diagram won't work, because DIM is loaded with a series circuit of a 2k resistor and BE diode.
The load on DIM needs to be >= 100k for the LED/driver to reach full brightness (see datasheet).
Try 100k for R11.
Remove D6. Useless, and also might prevent driver from reaching full brightness.

I still don't see why you don't want to use diagram#1.
Default behaviour of the LED driver (nothing connected to DIM) is full brightness.
Same with opto coupler and Arduino connected, and Arduino powered off.
Only an 'active' Arduino can dim this driver.
Why do you want to change this default behaviour (dimmed != off).
Are you not comfortable with the inverted logic examples I gave you in the PM?

Easy to invert by swapping the two outside wires of the control pot on the analogue input (if used).
Or to invert in code.
dimValue = 1023 - dimValue; // inverts a 10-bit value
dimValue = 255 - dimValue; // inverts an 8-bit value
dimValue = map(analogRead(dimPot), 0, 1023, 255, 0); // read and invert to 8-bit