Disclaimer: I am fairly new to this!
I would like to add backlight control to a Kuman 3.5” TFT LCD shield I bought from Amazon.
I already have it working but I had to guess and check and I’d like to understand WHY it works and make sure I’m not reducing the life of any components by doing something wrong.
As you can see in the attached photo, I removed resistor R1 which was a “2R0” SMD resistor, which Google says is 2 ohms. The right side of the resistor is a 3.3v supply. The left side goes to the 6 LEDs in the backlight, which then have 6 separate wires going to ground. I didn't see any other resistors. It's possible there are some inside the LCD display itself.
I want to control the LEDs via the left pin near “J3” which goes to Arduino pin A5. This pin is not used. When I digitalWrite(A5, HIGH) it is providing 5v, so I figured the resistor would need to be different.
I tried to calculate what resistor was needed but I don’t know the properties of the LEDs. I guessed and checked with an online calculator and decided that 91 ohm looked like it should work. I soldered the resistor between the left pad of R1 and the pin that connects to Arduino A5. It worked, but the LEDs were dim. I dropped down to a 43 ohm resistor and they’re still a little dim but it’s better.
I can continue to drop the resistor value until the display looks right, but I'd really like to calculate the value instead of guessing.
Of course I won’t leave such long resistor legs in the finished product. This is just for testing purposes.
Do you have a multi meter? Measure the voltage across the resistor. Then calculate the current through the resistor using the formula current = voltage / resistance (Ohm's law). You can reduce the resistance as long as the current is 20mA or less and still directly drive the LEDs with an output pin. If more current (than 20mA) is required, you will need to add a transistor to pass current over 20mA.
Thanks for the reply. I measured across the resistor as you suggested in a few configurations:
Default unmodified config (3.3V supply, 2 ohm resistor) = 0.259V, so current = 129.5mA if I'm doing this right. That's well over the 20mA you suggested, but that's the stock configuration. Does the fact that this is feeding 6 LEDs mean I should divide by 6? Then the current would be 21.58mA each.
5V supply, 2 ohm resistor = 0.62V, so current = 310mA (screen is very bright - resistor is hot)
5V supply, 43 ohm resistor = 2.05V, so current = 47.7mA (screen is a little dim - resistor is hot)
5V supply, 15 ohm resistor = 1.675V, so current = 111.67mA (screen is bright - resistor is hot)
5V supply, 12 ohm resistor = 1.568V, so current = 130.67mA (screen is bright - resistor is hot)
The 12 ohm resistor appears to provide almost the same current and screen brightness as the stock config, but it concerns me that the resistor gets hot. I'm using 1/4 watt resistors.
It seems like you did the measurements and calculations correctly. All of the current flows through the resistor (and into the pin) so that is the current that is important.
131 mA is way too much for an Arduino pin so a transistor will be required if you want to control the backlight brightness with an Arduino PWM pin. A5 is not a PWM pin, but will work for just on-off (with transistor).
To calculate the power that the resistor is dissipating the formula is power (W) = resistor voltage (V) * resistor current(A) so 1.57V * 0.131A = 0.206 W, which is near the rating of the resistor (0.250W) so it gets hot. You could use 1/2 Watt resistor or put 2 24 Ohm 1/4W resistors in parallel.
Ok, I've never used transistors before so I'll have to research those.
I noticed one thing that's a little odd...
I had been taking my measurements using the 5V pin above pin 23 on the Arduino Mega to power the LED backlight using jumper wires. I did this for convenience since my code turns off the normal pin, A5, after 10 seconds. I thought it'd be electrically the same but apparently it is not.
I took the same measurement using pin A5 instead, and I got this:
pin A5 (5V), 43 ohm resistor = 1.34V, so current = 31.16mA. The screen is a little dim but the resistor does not get hot.
Why would it have different values when both pins are 5V?