Controlling 20 LEDs with potmeter - Page 1
Forum section: electronics / projects

author: okw
author_rank: Frequent Contributor
timestamp: November 09, 2021, 04:23:59 pm
content: Hi! I'm trying to control 20 0805 LEDs with a potmeter. They shall illuminate and stay illuminated, one by one at the turn of the potmeter.It is two rows of 5 green 3 yellow and 2 red:GGGGGYYYRRGGGGGYYYRRAt potmeter 0 everything is turned off. The more I turn the potmeter, the more of the LEDs shall illuminate. Linear action is best.Two and two LEDs are in parallell so they light up at the same time:E.g. if potmeter is at 30%, it shall light the 3x2 first.xxxGGYYYRRxxxGGYYYRRI'm just mentioning that it's two LEDs at a time, since it then consumed double the amp.I would prefer the good old way with least and simplest components. And it's just for a demo, so it won't be used a lot.

author: tunk
author_rank: Super Contributor
timestamp: November 09, 2021, 04:32:04 pm
content: Arduino?How are the LEDs connected?

author: themadhippy
author_rank: Super Contributor
timestamp: November 09, 2021, 04:35:42 pm
content: QuoteCant get much more ole skool or simpler than the LM3914

author: CaptDon
author_rank: Super Contributor
timestamp: November 09, 2021, 04:39:09 pm
content: Just use the linear LED bargraph driver I.C.'s commonly available for about $1 each.They are available in 20Db linear step or 30Db logarithmic step and can be bargraphor single dot select able by the voltage applied to the selection pin.

author: rvalente
author_rank: Frequent Contributor
timestamp: November 09, 2021, 04:43:36 pm
content: Just go with an arduino. Much easier to do math/logic with code rather than analog electronics

author: okw
author_rank: Frequent Contributor
timestamp: November 09, 2021, 06:50:28 pm
content: Thanks for all the input. I was trying to avoid Arduino as I've done too many of those projects. I wanted to keep this simple project simple.I forgot to tell, it will be powered by 3V (2x AA batteries). I guess LM3914 isn't too happy with that?

author: Gyro
author_rank: Super Contributor
timestamp: November 09, 2021, 06:56:23 pm
content: Just fyi, the device name is potentiometer, not potmeter.

author: mariush
author_rank: Super Contributor
timestamp: November 09, 2021, 07:48:59 pm
content: A microcontroller would be easiest as you could simply measure the voltage with the ADC and enable led lines accordingly.a bar graph chip would work but that's also kind of a micro controller, being so complex.you could probably use some inverters with schmitt trigger to enable or disable an output depending on the input voltage coming into the inverter. then have mosfets/transistors connected to it, or the enable pin of a basic 1 channel led driver.

author: themadhippy
author_rank: Super Contributor
timestamp: November 09, 2021, 08:19:44 pm
content: Quotefrom the data sheet"Operates with Single Supply of Less than 3V "Quotethe lm3914 is 10 comparators,not sure i'd call it a micro controller

author: Zero999
author_rank: Super Contributor
timestamp: November 09, 2021, 09:10:10 pm
content: I don't see how a microcontroller would be a complex solution. It can be just one IC, a potentiometer, the 20 LEDs and associated current limiting resistors. The cheapest MCU, with an ADC and >21 I/O pins will do, such as the ATMEGA808.https://www.mouser.co.uk/ProductDetail/Microchip-Technology-Atmel/ATMEGA808-XU?qs=P1JMDcb91o4%2FnfibePr4Kg%3D%3DThe LM3914 is gradually getting more difficult to find and is becoming increasingly expensive nowadays. The LM339 is ⅒ of the price of the LM3914 on Digikey and will still be cheaper, when factoring in the extra resistors and board space.https://www.digikey.co.uk/en/products/detail/stmicroelectronics/LM339QT/2772250https://www.digikey.co.uk/en/products/detail/texas-instruments/LM3914VX-NOPB/367096I'd opt for five LM339 quad comparator ICs. Here's a circuit showing four LEDs with a single LM339. It's very easy to increase it to 20 LEDs. R10 just ensures the voltage at the top LM339's input is within the common mode range of 1.5V less than the positive supply rail.It can be replaced with an LED, or three silicon diodes, such as the 1N4148.

author: coromonadalix
author_rank: Super Contributor
timestamp: November 10, 2021, 12:38:49 am
content: the lm399 will do perfectly, you just have to redo the resistor network divider calculations to suit the range you need for each led ...For how long you need the led(s) to lit ?, you could add an buck converter to up/boost your voltage, but the battery life will diminish ...

author: okw
author_rank: Frequent Contributor
timestamp: November 10, 2021, 12:02:32 pm
content: Quote from: Zero999 on November 09, 2021, 09:10:10 pmThanks - this is exactly what I was looking for. The versatile LM339 is perfect.It only needs 10 outputs (every two LEDs are in parallell). So three LM339. I guess it's just to triple the cascading LM339 from your schematic?Btw, can the each LM339 output drive two 0805 LEDs (Aliexpress LEDs, so no datasheet but I guess 5-10mA is enough to properly light each LED)? The LM339 says low-level output current is 6mA (min) 16mA (typ). If not (or uncertain), should I replace with 0603?I have 1k, 2k, 5k, 10k, 50k and 100k pots and a kit of every 1% and 5% std resistor value. For best battery life, which pot and combination of resistors should I use (keep in mind it's powered by 2x 1.5V AA, not 12V as in your schematic)? I wouldn't mind learning how to calculate this, if you (or anyone) would like to help me? That's one of the reasons why I would try to avoid using an MCU.

author: okw
author_rank: Frequent Contributor
timestamp: November 10, 2021, 12:08:56 pm
content: Quote from: coromonadalix on November 10, 2021, 12:38:49 amNot for long (perhaps 5-10 min at a time), so battery life isn't a practical issue. But I don't want it to drain empty after say 10 times of 5-10 min use. I would like to keep the number of components and cost down without compromising LED intensity and battery life.

author: Zero999
author_rank: Super Contributor
timestamp: November 10, 2021, 03:05:57 pm
content: Quote from: okw on November 10, 2021, 12:02:32 pmAn MCU will use less power, than three LM339s, but it's unimportant, as the LEDs will dominate, unless it spends most of the time, with none of them illuminated.Yes, this circuit will work off two AA cells.The resistor values are unimportant.A 100k potentiometer will do.The resistors in the chain (R4 to R5 on my schematic) can be all 10k. The top most resistor (R10) will need to be much higher, to ensure the +input of the top comparator, is within its common mode range specification. I'd go for 150k, which will drop about 1.5V, when the battery voltage is 2V.You'll probably find modern LEDs will be bright enough when run from under 5mA. Don't worry too much about the worst case values given on the data sheet. It doesn't matter if the parts are a little worse than the typical. It will work, just the LEDs will be a little dimmer. I'd just go for a series resistor of 150R per LED. If you're having trouble with getting them bright enough, you could drive the LEDs with BJTs, but it's probably not needed.

author: okw
author_rank: Frequent Contributor
timestamp: November 10, 2021, 03:42:31 pm
content: Thanks.I also need to control 12 LEDs with two pots (6 LEDs each). Since the three LM339 leaves me with two unused comparators, i'll use these.I added a BJT since 6 LEDs will be too much for the output. Would this circuit work?I also want the PCB to accept both comparator and MCU (atmega328p).With MCU I'll omit all components left of R40 (comparator circuit) and POT_GREEN go to the ADC and MCU_GREEN controls the LEDs.I also have a solder joint on the pot (to relieve it from ground if I opt for MCU). With MCU I'll bridge R39. With comparator, I'll bridge R40.Will this work, or am I thinking wrong?

author: mariush
author_rank: Super Contributor
timestamp: November 10, 2021, 04:55:44 pm
content: It would be SO much simpler to just go the microcontroller + LED DRIVER IC route.You can get drivers with 8/16 channels or drivers that have configurable current for r,g,b channels (ex 18 channel driver where you can set 3 different current limits for each channel) and there's led drivers that can control 100+ leds in a multiplexing mode ( ex 30 x 6 led matrix, either 180 single color leds or 60 rgb leds :https://media.digikey.com/pdf/Data%20Sheets/ISSI%20PDFs/IS31FL3742.pdf)

author: okw
author_rank: Frequent Contributor
timestamp: November 10, 2021, 05:08:39 pm
content: Quote from: mariush on November 10, 2021, 04:55:44 pmSo is McDonald’s

author: Zero999
author_rank: Super Contributor
timestamp: November 10, 2021, 06:16:12 pm
content: Quote from: okw on November 10, 2021, 03:42:31 pmR40 is not needed.R41 is far too higher value.Ideally each LED should have its own current limiting resistor, but you can get away with one, if the LEDs are all from the same batch and will be run at much less than their maximum ratings.If you use NPN transistors, the + and - inputs to the comparators need to be reversed.If you use PNP transistors, the inputs don't need to be reversed, but the emitters will need to go to +V and the LEDs connected between the collectors and 0V.I'd recommend using a higher voltage, so more LEDs can be connected in series.You should definitely build this on a breadboard or strip-board, before ordering and PCBs.Quote from: okw on November 10, 2021, 05:08:39 pmI've never understood the reluctance to use a microcontroller by so many people. It isn't cheating. Writing the code is a real skill and requires some knowledge of the hardware.

author: okw
author_rank: Frequent Contributor
timestamp: November 10, 2021, 07:17:22 pm
content: Quote from: Zero999 on November 10, 2021, 06:16:12 pmIt's not reluctance, I've done it so many times. This time I wanted to learn another way.If I up it to 3x AA batteries, I still wouldn't be able to run more than 2 LEDs in series? Any other benefit than same current in all series LEDs, which gives same brightness.If I have 6 LEDs in series I would probably need at least 12V (say Vf=2V)?I used 150R for each 6 LEDs (900R). Or am I thinking wrong?Isn't R40 needed between MCU output to limit current?I'll flip the input comparators, and keep NPN. Or would there be any added benefit with PNP and reverse the LEDs?

author: mariush
author_rank: Super Contributor
timestamp: November 10, 2021, 07:56:13 pm
content: Quote from: okw on November 10, 2021, 07:17:22 pmDepends... 3 rechargeable batteries is 3 x 1.1v .. 1.35v = 3.3v .. 4.1v .. regular alkaline batteries will be ~ 1.4..1.6v ...Probably easier to use 4 AAA batteries, as you're most likely gonna recharge them in pairs anyway.A yellow led may have a forward voltage of around 2 ... 2.2v, as some green leds ... depends on chemistry used, i guess. Red usually has a lower forward voltage, 1.7v, even less (some are down to 1.2v) and human eyes are more sensitive to red, so you may need less current compared to the other.So 2 leds in series may require close to 4v.Keep in mind you're gonna have some drop across the transistors, across resistors, you need a voltage a bit higher than 2 x led voltage drop in series.

author: Zero999
author_rank: Super Contributor
timestamp: November 10, 2021, 08:21:09 pm
content: Quote from: mariush on November 10, 2021, 07:56:13 pmThe eyes are actually more sensitive to green and yellow, than red. It's just that red LEDs have a much higher efficiency than green and especially yellow LEDs.Colour is less of an indicator of the forward voltage, than it used to be. High efficiency, pure green LEDs tend to have higher forward voltages and some yellow and amber LEDs are really blue dies, with a phosphor on top to convert it to a longer wavelength and are much more efficient than the crappy old yellow LEDs.Quote from: okw on November 10, 2021, 07:17:22 pmUsing a higher voltage would result in a more stable brightness, because there's more voltage dropped across the resistor.No, the series resistor needs to be lower for six LEDs in parallel, as current is inversely proportional to the resistance. Look up Ohm's law.Yes, R40 would be needed for an MCU, but your drawing showed comparators.The advantage of using PNP transistors is, rather than the comparator shorting the base to ground, it doesn't supply any base current, when the transistor is off, thus saving a little power.

author: okw
author_rank: Frequent Contributor
timestamp: November 10, 2021, 09:22:56 pm
content: So I'll go for PNP and not flip the comparator inputs.Does this look good?I might get 4x AA and have 3 LEDs in series.Is the pot oriented correctly? So starting at 0 gives no light. Then at some point during the clockwise rotation, lights up all LEDs.How do I calculate R47?

author: james_s
author_rank: Super Contributor
timestamp: November 10, 2021, 09:51:21 pm
content: Obviously a microcontroller would be the easy way, but he specifically said he's done a lot of microcontroller projects and wants to try a different technique, so why do people keep suggesting a microcontroller? The tried and true LED bargraph ICs that are made of comparators seem like the obvious way to go.

author: Zero999
author_rank: Super Contributor
timestamp: November 10, 2021, 09:55:10 pm
content: Quote from: okw on November 10, 2021, 09:22:56 pmThat looks sensible enough, but now R46 is mandatory for the comparator. You might be able to get away without R45, but many people here would disapprove of it.

author: okw
author_rank: Frequent Contributor
timestamp: November 10, 2021, 10:31:16 pm
content: Quote from: Zero999 on November 10, 2021, 09:55:10 pmThat looks sensible enough, but now R46 is mandatory for the comparator. You might be able to get away without R45, but many people here would disapprove of it.Let me explain again. I'm creating a PCB with circuits for both MCU and comparators. R46 is only soldered to the PCB when MCU is soldered in. When comparators are soldered in, R46 will be solder bridged. Same with R45, it is only mounted when comparators are soldered in (since LM339 is open collector), and left open with MCU. I'll never mount both comparators and MCU on the same PCB. I'm just making it dual, since I'm getting 5 pcs on each order. So I'll play a little with both techniques.I agree LM3914 would be more elegant, but since I already need two comparators for the other two potentiometers (which controls independently), I think three LM339 is the way to go. And since buying in bulk, LM339 is more versatile to have in my bag.The potentiometer, do I need to solder all three legs? Or is VCC and wiper good enough? Keeping 100k tied to ground would slowly drain the battery.

author: themadhippy
author_rank: Super Contributor
timestamp: November 10, 2021, 10:37:28 pm
content: Quoteget wif it grandad,it gota have a microprocessor in it or aint proper lectronics like wot we get taught at skool

author: Zero999
author_rank: Super Contributor
timestamp: November 11, 2021, 08:12:41 am
content: Quote from: okw on November 10, 2021, 10:31:16 pmExcept you've got it wrong. If you're using PNP transistors, R46 is required to limit the base current, irrespective of whether an MCU, or comparators are used. It's only not required for comparators, if NPN transistors are used.You can get away without R45, if comparators are used, with PNP transistors, but it is required for NPN transistors. In either case, it's not required, with an MCU.This is because a BJT has a base-emitter diode junction, which requires a limited current and the comparator connects its output to 0V, when it goes low, i.e. it has an NPN open collector output.QuoteRefer to the schematics, I've posted.

author: okw
author_rank: Frequent Contributor
timestamp: November 11, 2021, 09:59:09 am
content: Thanks. Now it's more clear.Could I ask for a pinout question? I've bought a few RV09 potentiometers, and found an Eagle part that has exactly the same measurements. But I suspect the pinout is reversed.The 3 pins on footprint from left is 1, 2, 3 and symbol is 1 on the top, wiper on 2 and bottom 3. See attachment.The arrow in the symbol throws me off. The way the symbol is oriented and arrow pointing up, makes me think at @ 0 pin 2+3 is "shorted", and @ 10 (fully clockwise) 1+2 dominates.I want potentiometer fully counter-clockwise to turn off all LEDs. So I think pin 1 should be GND and 3 to the VCC resistor?

author: Zero999
author_rank: Super Contributor
timestamp: November 11, 2021, 11:16:08 am
content: The arrow corresponds to clockwise rotation, when looking straight at the potentiometer.The library could be right, or it might be wrong. The only advice I have is to check the data sheet.

author: okw
author_rank: Frequent Contributor
timestamp: November 15, 2021, 07:25:50 pm
content: I had the bite the bullet and go for a microcontroller. I had to use rotary encoders instead of potentiometers, so I decided to use a TLC5925 (basically a shift register with 16 constant current sinking outputs).I have created a new thread, asking a few questions about about driving different loads with this:https://www.eevblog.com/forum/projects/tlc5925-driving-different-v_f-and-i_f-leds/If anyone have input on this, I would be glad.