Looking for advice on simple led & switches circuit - Page 1
Forum section: electronics / beginners

author: e1p3dr0
author_rank: Contributor
timestamp: November 25, 2020, 09:58:51 am
content: Hi all,I'd be grateful for your advice on building a very simple LED circuit. It will just be a load of LEDs wired in parallel, with each led controlled by its own switch, and all powered by a standard battery power source e.g. AA, or 9V or something.I suspect there might be as many as 20 or 40 leds.Q1) Circuit layoutDo I just need to put an appropriate resistor and switch in series with each LED?Q2) Power consumptionGiven that I'm only talking about single digit voltage and standard LEDs (so circa 2V), am I right in thinking that the cumulative power loss from all the resistors will be pretty insignificant even though there will be so many of them - or should I be thinking of a different circuit design that already steps the voltage down before splitting into the parallel branches?Q3) Minimising purchase costAlso, I'm looking to keep cost to a minimum. The LEDs are pennies, which is fine. But what's the cheapest type of switch (other than manually connecting/disconnecting two wires)?**Edit**Q4) BatteryWhat battery makes the most sense? 9V or 2x AA batteries or someother combo?

author: Nusa
author_rank: Super Contributor
timestamp: November 25, 2020, 11:26:05 am
content: Q1: Yup. The trick is determining what is "appropriate" for your application.Q2: Insignificant is in the eye of the beholder. It'll be a simple sum determined by how many LED's are lit, along with how wisely you chose the resistors. 10-30 ma per LED is the common range, but that will vary based on LED color and brightness you require.Q3: You have to define what kind of switch you want first. In general, momentary push button pcb mounts can be found cheapest, but that might not meet your needs.Q4: Once again, you need to define your needs and the space available. How long does it have to last between battery changes? How much power (number of LED's lit) will it draw on average?It's all math in the end. Ohms Law, Watts Law, and the datasheets for the LED's in question are the main things you need.

author: Microdoser
author_rank: Frequent Contributor
timestamp: November 25, 2020, 12:16:52 pm
content: If you need to control 40 LEDs individually then you are edging into a case where an arduino and a multiplexer would be cheaper and more reliable than 40 individual switches and would give you more functionality.Cheapest slide switches I can find on Digikey are £0.42. 40 of those is over £16, easily more than the cost of a small microcontroller and a mux.There is also the issue of the sheer size that 40 switches take up.But to answer your questions,Q1: yesQ2: for 40 LEDs you are looking at possible 1.2A@2V, if you run 5 strings in parallel from a 9V battery you could get your amps down to 240mA@1.8V. This would reduce the size of wire you would need for one. You can easily figure how long your 9V battery would last putting out 240mA. Stepping down your voltage would introduce extra power losses that you could avoid by using a different design, like running your LED lights in parallel.Q3: 40 switches will be your main cost and will be difficult to reduce, I would examine other ways to control 40 devices than using switches.Q4: Only you can define what 'makes the most sense'. Is your main design consideration size, longevity, cost, ease of construction? each will have a different 'best design'

author: e1p3dr0
author_rank: Contributor
timestamp: November 25, 2020, 12:25:47 pm
content: Thanks for the answersI'm still feeling things out, so haven't got to the stage of putting specs together. In the meantime, I think I should give a bit more context to help narrow the scope of my questions:My daughter and I are going to build a 3-bit boolean adder circuit from first prinicples. The emphasis of this project will be to get down to first principles of logic as opposed to electronics. So we won't be using logic gates or any integrated circuitry, but instead she'll perform the actions of the logic gates by flicking switches. The leds will be used to indicate the binary value (on = 1, off = 2) of the inputs and outputs either side of the 'logic gate' (i.e. manual switch). That's why the switches are unfortunately completely integral to this concept.So, wrt Q2, power consumption:None of this has to have production-grade efficiencies or conform to any environmental constraints such as size, wire guage, time between charges. Nevertheless, in the background I do want to give her a sense of good circuit design. So I don't want to inadvertently design a circuit that is obviously 'bad' - where bad in this case might be wasting a load of mAh heating up resistors. But I'm starting to see that that is highly unlikely because of the low currents that this circuit will require.Q3. These switches will have to hold their state. So a toggle switch rather than momentary push. But I think you've probably pushed me in a promising direction regarding PCB mounted switches - they seem waaaay cheaper than the kind of old-school flick switch I had originally envisaged.Q4. This circuit will only be a demonstrator which is turned on for 5 mins at a time, and probably only a few times before it's dismantled again! Before getting round to drawing the diagram, I estimate that somewhere in the region of 20-40 LEDs will be used and any number of them may be lit depending on the numbers she's adding.

author: e1p3dr0
author_rank: Contributor
timestamp: November 25, 2020, 12:36:45 pm
content: Quote from: Nusa on November 25, 2020, 11:26:05 amQuote from: Microdoser on November 25, 2020, 12:16:52 pmAh. I'm starting to understand. The super cheap ones are _all_ momentary push. Those sliders are a significant step up in price (given the number of them that I might need). I think I need to actually get down and sketch out the circuit to figure out exactly how many I'd require.

author: Microdoser
author_rank: Frequent Contributor
timestamp: November 25, 2020, 02:19:40 pm
content: That makes it easier to understand. So, for the limited use time this will have, I am not sure (from a battery life perspective) it matters which battery type you use. If you want to minimise resistor losses then I would say to use a battery which puts out a voltage as close as you can get to the individual LED voltage so your resistor value will be low, and so will your resistor losses. The current an LED uses is related to the voltage applied to it, less voltage less current. What this means is that you want to drop as little voltage across your resistor as you can so that more power is used dropping the voltage across your LED so the closer your supply voltage is to your LED voltage, the lower your losses in heat and the greater the portion of the power which is turned into light.In your case, that would be to use 2AA batteries giving you 3V.Here is a site with an article about calculating the resistor value you need for an LEDhttps://www.circuitspecialists.com/blog/how-to-determine-resistor-value-for-led-lighting/The exact value of resistor depends on the resistance of your LEDsIf you are making a board anyway, you might want to look at having one voltage converter capable of supplying the maximum 1.2A that can drop your voltage to the required 2V so no resistors would be needed. You may find you have less overall losses doing it that way.Here is a handy website for designing power converters from TI. Not sure it would help with this project, but it might come in handy in the future.https://www.ti.com/design-resources/design-tools-simulation/webench-power-designer.htmlYou can tell it your input (AC/DC and voltage) and then your required output, 2V at 1.2A in your case, and it will give you a few designs that are capable of doing that. You can sort them by cost, the number of components, size, efficiency etc. A lot of times it suggests SMD components though but some of the cheaper designs cost roughly similar amounts to 40 resistors and for just LED lights ripple or other power supply considerations can be ignored.You could then try out various combinations, like 2AA batteries, a 9V battery etc and see if it comes up with a cheap, simple design.More suited to your immediate needs, on Ebay just now I see they sell 'LM2596S DC-DC Power Supply Buck Converter Adjustable Module 3A' which would fit your needs. They cost £1.55 each delivered and the specs seem to be close to what you would need:Name / number LM2596S DC-DC step-down moduleInput voltage 3.2V 40VOutput voltage 1.25V 35VOutput current 3A (max)Conversion efficiency of 92% (maximum)If you used 3AA batteries (4.5V) or a 9V battery you could set it to put out 2V and easily power your entire project with it with no resistors.I am not sure you can escape the cost of switches from the sound of things but the buck converter should reduce the amount of soldering you have to do to construct it

author: Nusa
author_rank: Super Contributor
timestamp: November 25, 2020, 03:05:43 pm
content: In that case, I'd suggest a 5V USB input cord to eliminate the battery part. Then you can use a 2-3 amp phone charger when an outlet is handy or a rechargeable USB battery when it's not. Fair odds you already have both of those on hand.If you want cheap slide switches and are willing to wait a month or so, there's always Aliexpress. Bet you can get 50 of them for a few bucks/pounds, shipped.

author: ledtester
author_rank: Super Contributor
timestamp: November 25, 2020, 07:39:31 pm
content: Capacitive touch switches might work for you:https://youtu.be/XBHgJi6smlsCan be configured for either on/off or momentary operation.They even come with an indicator LED.Search amazon/ebay/aliexpress for "TTP223".

author: wizard69
author_rank: Super Contributor
timestamp: November 26, 2020, 01:29:39 am
content: As someone else suggested you may want to look at microprocessor control. We are not talking just Arduino here but rather any suitably powered microcontroller. To actually switch all of those LED's you might want to look into some of the specialized IC's available for driving LED matrix's. TI for example has a bunch of such chips of various types. Your push buttons would be input to the processor and the processor and driving chips would handle driving the corresponding outputs (LED's)By the way not trying to totally dismiss manual switching for you just that it might not make much cents. Yes cents as a bunch of bi stable switches will cost a good penny and take up a big of space. The various driver IC's from TI offer a lot of features too that you would have a hard time implementing with discreet solutions.In any case your project has to limit the current through each LED chip. This of course depends upon the power supply and the rating of the LED's.Lets say though that you do go with say micro toggle switches. You can get these PCB mounted, so that isn't a real issue though you may have an issue with bounce.More interesting I'm not sure why you want to avoid IC's. Implementing a bunch of logic gates with discreet components doesn't strike me as a good way to learn about adders and logic circuits. Maybe one gate but that is a maybe, your approach seems to be anti educational. As a kid I think this would drive me away from any interest in digital technology. I would think it would be more important to show the intermediate states between gates with LED's which will require drivers and such. The more I think about it I'm not sure what the goal here is.

author: gcewing
author_rank: Regular Contributor
timestamp: November 26, 2020, 02:55:17 am
content: You might like to think about using relays as logic elements. Much less mysterious than electronic gates -- anyone who understands how a switch works shouldn't have any trouble with relays -- while being more in the spirit of logic circuitry than a bunch of manual switches.You should be able to build a 3-bit adder with 6 input switches and a handful of relays with DPDT contacts.

author: e1p3dr0
author_rank: Contributor
timestamp: November 26, 2020, 10:37:58 am
content: Quote from: ledtester on November 25, 2020, 07:39:31 pmOh! those are great. And cutting the power will reset them all, which is a bonus.In themselves, they are more sophisticated than a switch and a lot less obvious to a child how they do what they do (compared to a manual switch). So they are a step towards the kind of black-box that I'm trying to avoid. But they don't change the fundamental approach - she'll still be able to see at a glance the order of connections, the actual logic decisions will all still be manual, and she'll still have to do them in order.

author: e1p3dr0
author_rank: Contributor
timestamp: November 26, 2020, 12:02:28 pm
content: As long as I embrace XOR, it's 5 switches per full adder, another 2 for the first half adder, and then two per bit (because we're adding two numbers) to define the input numbers.I.e. 18 switches for a 3-bit adder, or 25 for a 4-bit.Or for an adder/subractor, each bit requires a full adder, plus an additional xor per bit, then the 2 switches per bit to set the inputs, plus the plus/minus control switch.i.e. 25 for a 3-bit adder/subtractor or 33 for 4 bit.It'd be a bit of a slog to work through 25 logic determinations, so I'm going to stick with a 3-bit adder.As for the LEDs... I'll have one at each logic gate input, and one at the output. Then additional LEDs for the bits of the numbers to be added and an LED for each bit of the result.By my calcs that's 46 LEDs. Maybe I'll go for red as an input and green as an output of the logic gates, and perhaps I can go for a third colour for the numbers to be added and the result.Probably going for 3-bit adder, 5V plug in supply like Nusa suggested. Reckon this is going to cost best part of £15 in order to be able to add up to 14! I'll let you know if it was worth it.