Variating 5v voltage

Hi, I'm pretty new to Arduinos and am making a project where I use a photoresistor to change the brightness of an LED. It works fine but I want to use some LED strings that need 5v to run but I am relying on PWM ports to change the brightness. I tried using NPN transistors but don't want something binary of course, any help?

(P.S its 11 at night i accept i might be being dumb :P)

PWM IS binary, and is the 'normal' way to dim LEDs. Your use of an NPN Transistor (or ideally a MOSFET) would be rthe accepted way to do this.

use IRF540

This is not a logic level mosfet since Rds(on) is quoted at 10volts only (although it might work at 5 volts)

SiRA50ADP - 4.5V?

Hi, @cosmonautical
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

Can you post your code and a circuit diagram that you used NPN transistor?
It will be a start to helping you.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Here are 2 options that are typically used.
The N-channel MOSFET should be a Low Rds part with a logic level gate that turns fully on with 4.5 to 5V such as AOD4132, which turns on full at 4.5V and has 0.006 ohm resistance.

Interesting project.
I wonder have you considered an alternative solution? Using WS2818 RGB LEDs.
You might like to research those.
The only downside might be the physical spacing between the LEDs in the WS2818 strip might not match what you need.

Looking a bit like a dead thread! :woozy_face: