# Not getting expected voltage at LED

I recently picked up and arduino nano kit and messed around with all the simple projects. I dont have much EE experience besides those so I have a question that might be pretty basic.

I am trying to make a simple travel lantern with a rechargeable Li-ion battery pack. It is working, but the voltage at the LED is below what I calculated it should be and thus the LED is dimmer than expected.

I'm using a 18650 3.7v Li-ion battery for power that is connected to a TP4056 charge/protect board. The TP4056 output is connected to a MT3608 step-up boost converter to boost the 3.7v up to 7v which powers the Nano through pin 30. I know that is not an efficient way to power it but I will be changing that in the future.

I want to use PWM to control the brightness using a rotary encoder and the push button to turn it on/off. The LED was salvaged from a flashlight I had around and after some research it looks like it is a cree xp-c which lists a forward voltage of 3.6v @ 350mA. To reduce the 5v max output of the arduino pins I made a voltage divider with R1 being a 100 ohm resistor and R2 being 330 ohms. This should cause the output between the resistors to be ~3.8v, but since the arduino puts out a bit less than 5v I expected ~3.6v output.

The issue is that I am getting 2.6v to the LED instead of the 3.6v it should be. I measured 4.5v from pin D6 to GND but only 2.6v after the divider. What could cause the voltage to be 1v lower than expected?

Here is the code I have on the nano:

int tempPin = 0;

volatile boolean TurnDetected;  // need volatile for Interrupts
volatile boolean rotationdirection;  // CW or CCW rotation
volatile boolean isOn;
volatile boolean buttonPress;

const int PinCLK=2;   // White
const int PinDT=4;    // Orange
const int PinSW=3;    // Brown
const int PinLED=5;

int counter = 100;

// Interrupt routine runs if CLK goes from HIGH to LOW
void isr ()  {
delay(4);  // delay for Debouncing
if (digitalRead(PinCLK))
rotationdirection= digitalRead(PinDT);
else
rotationdirection= !digitalRead(PinDT);
TurnDetected = true;
}
void isr1 ()  {
delay(4);  // delay for Debouncing
if(!digitalRead(PinSW)){
isOn = !isOn;
}
buttonPress = true;
}

void setup() {
isOn=false;
Serial.begin(9600);
pinMode(PinCLK,INPUT);
pinMode(PinDT,INPUT);
pinMode(PinSW,INPUT);
pinMode(PinLED,OUTPUT);
digitalWrite(PinSW, HIGH); // Pull-Up resistor for switch

attachInterrupt (0,isr,FALLING);
attachInterrupt (digitalPinToInterrupt(PinSW),isr1,FALLING);

}

void loop() {

if(buttonPress){
if(isOn){
int val = map(counter, 0, 100, 0, 255);
analogWrite(PinLED, val);
} else {
digitalWrite(PinLED, LOW);
}
buttonPress=false;
}

if (TurnDetected)  {
if (rotationdirection) {
counter+=2;
}
else {
counter-=2;
}
if(counter > 100){
counter=100;
}else if (counter < 30){
counter = 30;
}
int val = map(counter, 0, 100, 0, 255);
analogWrite(PinLED, val);
TurnDetected = false;  // do NOT repeat IF loop until new rotation
detected
Serial.println(counter);
}
}


## 1 Answer

Arduino outputs are typically limited to 20mA with a voltage drop of 0.3 to 0.8V depending on the microcontroller used.

For 350mA leds, you need at minimum a mosfet or transistor, and preferably a constant current driver.

Resistor voltage dividers will be very very poor in this type of situation. You'd be better off using just a single resistor.

• It's my understanding that if I used a mosfet I would lose ability to use PWM to control the brightness of the LED. Sep 2, 2018 at 22:54
• No, the mosfet would respond to the pwm just as much as the led. Sep 2, 2018 at 22:58
• @Loxez Essentially, you don't need a voltage divider. R2 is causing the problem. Remove it entirely, and select a value for R1 that gives the correct current through the LED. Sep 3, 2018 at 8:58