Hello, I want to control the intensity of a high-power LED so it cycles between 20 and 50% with smooth transitions. I want to use 700mA luxeon start led with a driver.
My question if i can use a IRLZ44N MOSFET like the one bellow:
(circuit 2)
Possibly not. A high power led needs a constant-current driver. These drivers may not work correctly if you use PWM to switch on and off either their inputs or their outputs.
If you can find a constant current driver with an enable input, you may be able to feed the PWM signal from and Arduino pin and not need to use any MOSFETs.
Look for a "constant current" dimmable LED driver. (It's actually controlled current if it's dimmable.) They are like switch-mode power supplies but designed for constant current instead of constant voltage. It's NOT an easy thing to build yourself.
LEDs (like all diodes) are nonlinear. Their resistance changes with voltage. They are pretty-much the opposite of everything else... You feed then the correct current and the voltage "magically" falls into place. A "normal" power supply or driver tries to hold the voltage constant.
Alternatively, you can use a simple MOSFET driver with "extra" voltage" and resistor to control/limit current, like with a "regular" little LED. LED Resistor Calculator. To work best, you'll probably need at least 18V. And, you'll need a resistor that can handle the power.
A resistor is rarely used for high power LEDs because it's inefficient and related to that, it generates extra heat.
Speaking of heat, "bare" high-power LEDs usually need a heat sink.
Thank for the feedback. Now i have a silly question that could find a solution. The program works well when I power the arduino with the USB cable. But if use a 9V into the barrel, which i split into the LED driver, the program (fade in/out) does not work. Any suggestions?
The input to the buck need to be at least 2.5V higher than the LED(s) forward voltages(s).
So if you three 3.0V LEDs in series the the input voltage need to be 11.5V.
Also a 9V battery won't be able to supply the current for a 700mA LED.
Thanks, I am using a 9V 2A power adapter. The buck puc drives two luxeon 2.1V LEDs.
Shouldn't this power supply allow the arduino to run the program and the LEDs? Going to 12v is a bad idea right? Added a photo if it helps. Thank you!
Thanks for your patience!
It does not run the script. I remove the USB and plug the barrel.
I'm using the script bellow -sorry, I'm an almost ignorant on the matter
const int ledPin = 9; // PWM-capable pin
const int brightnessLow = 0; // 20% of 255
const int brightnessHigh =30; // 50% of 255
const int fadeStep = 1; // Smaller step = smoother fade
const int fadeDelay = 100; // Delay between fade steps in milliseconds
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
// --- Fade from 50% down to 20% (if starting from high, else this is skipped first cycle)
for (int i = brightnessHigh; i >= brightnessLow; i -= fadeStep) {
analogWrite(ledPin, i);
delay(fadeDelay);
}
// --- Stay at 20% brightness for x milisecond
analogWrite(ledPin, brightnessLow);
delay(500);
// --- Fade from 20% up to 50%
for (int i = brightnessLow; i <= brightnessHigh; i += fadeStep) {
analogWrite(ledPin, i);
delay(fadeDelay);
}
// --- Stay at 50% brightness for x miliseconds
analogWrite(ledPin, brightnessHigh);
delay(500);
}
Try this code
I added some code to blink the onboard LED.
So after you connect the 9V to the barrel jack, push the reset and the LED should blink 10 times
const int ledPin = 9; // PWM-capable pin
const int brightnessLow = 0; // 20% of 255
const int brightnessHigh = 30; // 50% of 255
const int fadeStep = 1; // Smaller step = smoother fade
const int fadeDelay = 100; // Delay between fade steps in milliseconds
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
// Blink the LED
for (int j = 0; j < 10; j++)
{
digitalWrite (LED_BUILTIN, LOW);
delay (300);
digitalWrite (LED_BUILTIN, HIGH);
delay (300);
}
}
void loop() {
// --- Fade from 50% down to 20% (if starting from high, else this is skipped first cycle)
for (int i = brightnessHigh; i >= brightnessLow; i -= fadeStep) {
analogWrite(ledPin, i);
delay(fadeDelay);
}
// --- Stay at 20% brightness for x milisecond
analogWrite(ledPin, brightnessLow);
delay(500);
// --- Fade from 20% up to 50%
for (int i = brightnessLow; i <= brightnessHigh; i += fadeStep) {
analogWrite(ledPin, i);
delay(fadeDelay);
}
// --- Stay at 50% brightness for x miliseconds
analogWrite(ledPin, brightnessHigh);
delay(500);
}