# How to vary DC (0-450mA) current using Arduino output voltage(0-5 v DC)? [closed]

I want to vary output DC current(0-450mA) Of LED driver keeping voltage constant using arduino output voltage (0-5 Volt) is there any IC or current regulator operated on arduino (0-5 volt )i.e at 0 volt(of arduino ) 0mA current and if 5 volt(of arduino ) 450mA current i.e whene i increase or decrease output voltage of arduino then output current of driver is also increase or decreases respectively

• similar QA here: electronics.stackexchange.com/questions/19877/… – Umar Jan 20 '17 at 5:58
• Which Arduino are you using? Most don't have a real analog output, but only pulse width modulation outputs that can be used with some additional circuitry to emulate an an analog output. The ones I know of with real analog output are the Due, the Genuino, the Zero, and the MKR1000. Those one or two real analog outputs each. – JRE Jan 20 '17 at 6:04
• Arduino does not have a voltage output, but PWM can be filtered to give one. Is it that you want to control the birightness of the LED? If so, then using the PWM output to directly switch a constant 450mA on and off into the LED is a better solution. Otherwise you need a filter to remove the switching frequency on the PWM output, and a V to I converter to run the LED, which will change the output voltage, there is no choice in this, it's what happens. – Neil_UK Jan 20 '17 at 6:25
• Possible duplicate of Voltage Controlled Current Source integrated circuit? Exists? – Artūras Jonkus Jan 20 '17 at 7:15
• In that case, recommend you use Arduino PWM output to drive a switching FET and control your LED brilliance by PWM, as @Passerby answered and others commented. – TonyM Jan 20 '17 at 8:14

As this is roughly linear, you would use an LED Driver with an enable and/or PWM pin. Use PWM on the output pin of your Arduino. At 100% PWM, the full current will be seen 100% of the time. At 50%, the average current seen in the time period will be 50% of the full current. I.E. 450mA for 1/2 second and 0mA for 1/2 second is 225mA over 1 second average.

As LED lighting is not linear though, you will not see the LED at 50% brightness. We perceive brightness Logarithmically. Adjust your PWM as you see best.

What you're talking about is a voltage to current converter. You can roll your own using an op amp and a MOSFET. simulate this circuit – Schematic created using CircuitLab

A few notes which you must pay attention to:

1) R2 must be rated for at least 3 watts. It carries as much current as the LEDs, and at full current is dropping 5 volts to match the control voltage.

2) V1 must be about 8 to 10 volts greater than the LED voltage. It must supply the LED voltage plus 5 volts for R2 plus a few volts for the MOSFET.

3) V2 cannot be 3.3 or 5 volts. I don't care if that's convenient because you're already providing it for the Arduino. You need to provide an output of at least about 9 volts - 5 volts for R2 and 4 volts for the gate drive of the FET (and maybe a bit more). So 12 volts is a minimum, and 15 is better.

4) Because you want to control the current down to 0 amps, you cannot run the op amp as a single-supply, or at least not reliably. V3 must be a negative voltage, and for the TL081 it's a minimum of -5 volts. Getting +/- 12 or +/- 15 is easier.

5) The MOSFET must have a heatsink.

There are tricks you can play, such as simulate this circuit

Here, the input resistors divide 5 volts down to 455 mV, and a convenient 1 ohm resistor will produce 455 mv for 455 mA. This uses more resistors, but the sense resistor becomes a very convenient value, and it power dissipation drops to less the 1/4 watt. This also reduces the requirement for excess voltage from V1.

Overall, this is simple and reliable, but it takes more parts than a dedicated LED driver.