2
\$\begingroup\$

Update: Worked out a rough (I'm sure) schematic of the current idea for a smaller version of the circuit. A bit of info before the question;

The Arduino has a current cap of 200ma across all I/O pins, with a single pin good for 20ma. This is described as "pull or sink", which I assume means current into, or out-of.

Will the parallel switches, in their high number, try to draw too much current through the arduino from its GND pin due to the LED's, or will it remain at a healthy level (thanks to the pulldown resistors, or some other sorcery I've missed)? Exact values haven't been figured yet, but I'm assuming roughly the full 15-20ma per-LED(They will almost certainly be burning at a lower current, but I'd like as much wiggle room as I can wrest).

schematic

simulate this circuit – Schematic created using CircuitLab

Edited for clarity.

I'm attempting to wire 34 LED-illuminated toggle switches to an Arduino Mega. I need the Mega to be able to read the state of these toggles while still being able to utilize the LED indicators. The indicator needs to be on while the switch is closed, and off while the switch is open.

These switches have a much lower forward voltage than the 12v supply that I am powering the project with, and so I need to find a way to step the voltage and current down to something the Arduino can digest. The questions, therefore, are as follows;

1: Since the 34 toggles need to be individually readable, I will need to (if I understand correctly) wire their ACC output to the Arduino's I/Os individually. This means I will need to create a rather large parallel circuit from the 12v supply, over through the switches, and down into the Mega. Is there a way that I can do this that won't cause an immense heating issue? Will the current from the large number of parallel branches build up and try to kill my Mega, or can I use resistors to limit the current without causing more issues? Will these create a heating problem?

2: The 12v stepped down to 5v would be ideal, as prefacing the Voltage Regulator I foresee using for said stepdown, there is a 12v LED strip that I need to drive to serve as a backlight. This will be kept separate from the Arduino, and is simply controlled by an on-off toggle switch. Will wiring this strip in parallel to the voltage regulator cause some unforeseen issues with the rest of the circuit?

https://www.adafruit.com/product/1476

https://www.adafruit.com/product/3218

https://www.adafruit.com/product/1439

LM2596 Stepdown regulator

\$\endgroup\$
  • 3
    \$\begingroup\$ Welcome to EE.SE. One thing first: this isn't a forum, it's a question and answer site. I've scanned through your post but it's hard to tell what the question is. Can you edit it down to the relevant parts (why have you included the REDACTED part?) or, better again, just ask one specific question. e.g. "How can I read 34 switches with my microcontroller? I have 17 GPIO pins available for the task." \$\endgroup\$ – Transistor Dec 31 '19 at 20:04
  • \$\begingroup\$ congrats on being the 1st to use the word "termage" = Terminology for thick people,, Try 3 to 5mA only for indicators unless you are TDM (time division muxing) the output current of 16 mA in a 4x4 Mux... and input switches via a XY matrix like a keypad scanner with two quad CMOS switches \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Dec 31 '19 at 20:10
  • 2
    \$\begingroup\$ I tried to remove 80% of the chitchat to make this somewhat readable. \$\endgroup\$ – Marcus Müller Dec 31 '19 at 20:18
  • \$\begingroup\$ You really just need to read up on series resistors, and how to use NPN transistors as low-side switches for your LEDs so that the current doesn't have to be sunk into your microcontroller; done. \$\endgroup\$ – Marcus Müller Dec 31 '19 at 20:19
  • 2
    \$\begingroup\$ Your edits have made a major improvement in the question. +1 \$\endgroup\$ – Transistor Dec 31 '19 at 20:29
2
\$\begingroup\$

These switches have a much lower forward voltage than the 12v supply that I am powering the project with, ...

Switches don't have a forward voltage. The resistance of the switch will be very low when closed and the voltage drop across them will be very low.

... and so I need to find a way to step the voltage and current down to something the Arduino can digest. The questions, therefore, are as follows;

Run the switches and LEDs from the same PSU as the microcontroller - typically 5 V.

1: This means I will need to create a rather large parallel circuit from the 12 V supply, over through the switches, and down into the Mega. Is there a way that I can do this that won't cause an immense heating issue? Will the current from the large number of parallel branches build up and try to kill my Mega, or can I use resistors to limit the current without causing more issues? Will these create a heating problem?

The microcontroller will draw a current dependent on it's input impedance which will be in the order of 50 to 150 kΩ due to the internal pull-up or pull-down resistors. On a 5 V supply this results in a current of < 0.1 mA per switch giving P = V × I = 5 × 0.1 = 0.5 mW. Heating will not be a problem.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. The pushbutton and toggle switch schematics and how to use them. The circuit relies on built-in pull down resistors on the inputs. If you don't have them you'll have to add in external pull-downs.

2: The 12v stepped down to 5v would be ideal, as prefacing the Voltage Regulator I foresee using for said stepdown, there is a 12v LED strip that I need to drive to serve as a backlight. This will be kept separate from the Arduino, and is simply controlled by an on-off toggle switch. Will wiring this strip in parallel to the voltage regulator cause some unforeseen issues with the rest of the circuit?

No.


From the update to the question:

The Arduino has a current cap of 200ma across all I/O pins, with a single pin good for 20 mA [capital 'A' for ampere]. This is described as "pull or sink", which I assume means current into, or out-of.

Correct. Sink is current into the GPIO when used as an output. The opposite would generally be referred to as 'source' rather than 'pull'.

Will the parallel switches, in their high number, try to draw too much current through the Arduino [capital 'A' for Arduino] from its GND pin due to the LED's, or will it remain at a healthy level (thanks to the pulldown resistors, or some other sorcery I've missed)?

The microcontroller is only monitoring the actual switches and will draw negligible current from them. The LEDs are fed from the voltage regulator, not the Arduino microcontroller so there is no problem there.

Exact values haven't been figured yet, but I'm assuming roughly the full 15-20 mA [capital 'A' again] per-LED. (They will almost certainly be burning at a lower current, but I'd like as much wiggle room as I can wrest).

Just add them all up and check that your regulator can provide the required current.

The Arduino's microcontroller doesn't have internal pull-down resistors so you need R2, 3 and 4 but wire them and the LEDs as shown below.

schematic

simulate this circuit

Figure 2. Corrected version of OP's schematic.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thank you for the information. I believe the voltage drop I mentioned for each switch was due to the integrated LED, and that may have been what i took away from some earlier research. My arduino has built-in 20k pull-up resistors for input pins that can be accessed from software, but I'm not seeing anything about integrated pull-downs. Adding external pull-downs should not be problematic. I will work with these schematics and experiment a bit... as well as print out a bunch of component data sheets, now that I know how to find them. I will consider this answered. \$\endgroup\$ – YeehawsFromSpace Dec 31 '19 at 21:06
  • \$\begingroup\$ A request for clarification if I may; if the LED is powered on through ground from the switch, does that mean the leds being powered will not affect the Arduino input, or will it be drawing current out from the arduino's ground as it all flows away? Is that not how it works? It would be great if it were as simple as "5v to switch, ACC to input, ground to ground; rinse amd repeat 34 times without problem." (sorry for the early ping, I'd hit enter much too soon.) \$\endgroup\$ – YeehawsFromSpace Dec 31 '19 at 21:44
  • 1
    \$\begingroup\$ Add a simple schematic to explain your idea as an update to your question. You can add one in using the CircuitLab button on the editor toolbar. Double-click a component to edit its properties. 'R' = rotate, 'H' = horizontal flip. 'V' = vertical flip. Note that when you use the CircuitLab button on the editor toolbar and "Save and Insert" on the editor an editable schematic is saved in your post. That makes it easy for us to copy and edit in our answers. You don't need a CircuitLab account, no screengrabs, no image uploads, no background grid. \$\endgroup\$ – Transistor Dec 31 '19 at 21:56
  • \$\begingroup\$ I'll get on that -- thank you greatly for the info, and your patience. \$\endgroup\$ – YeehawsFromSpace Dec 31 '19 at 21:59
  • 1
    \$\begingroup\$ Current flows in a loop. Current flows from regulator +, through the switch contacts, through the LED and series resistor, to ground and back to the regulator -. It won't affect the Arduino. \$\endgroup\$ – Transistor Jan 2 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.