Inline leds with a toggle switch

i am making a button box for flight simulator. I want to put my leds in line such that whenever the gear of the aircraft is down(switch is toggle on) its a simple spst switch(s-1al) its quite realistic and used on many small aircraft's the lights in this case three smd leds turn on.

i am having a tough time figuring out the circuit for this with the pro micro.The leds i want them to be inline/hardware activated that way i wont need a extra pin to turn the lights on plus less code.

would it be possible to drive the three leds based on the input(analog,digital) pins current since that would be used to detect the switch movement. i have the two pins of the switch wired to D6 and D16 on the pro micro

You need a MAX7219 serial LED driver. Check out this thread:
https://forum.arduino.cc/t/how-to-control-simple-10-led-bar-graph-with-max7219
Do you have a plan to read 4 switches to on input? You could use a resistor network:

There are a few different library choices for these so look at multiple examples, but in general you can come close to your diagram.

Work on one piece at a time. Start with the switches. Make them print to serial when they come on and off.
Then work on the LEDs.

GitHub - MHeironimus/ArduinoJoystickLibrary: An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support. is what i am going to use,since it has built in autogenerated code to a extent for flight simulator boxes. I have to print them to high low signal,for it to work. Thus some sort of current/electricity based would have been great. everyone seems to be using this,but i have seen people complain how sometimes instead of 1 button press 4 are registered. i will start working one at a time and see how it goes. if a pin is left i might just wire the 3 leds to that pin but i dont think with flaps etc coming in anything will be left.

The above diagram is not mine,plus i am not using so many siwtches.mines has linear pots and rotary pots. just a single row of switches. Also what is a register network,i have heard about it people suggesting resistors and diodes are there any good examples. Where do the registors go and of what value ?

One of the link that I provided you explains the resistor network and provides a library to use it, but that's no longer applicable as you are using many pins for your switches.

I don't think you'll get the results you want with that diagram as the pots on the LED matrix are part of the design and you are now powering all of the LEDs through the board.
You really should consider using the MAX7219 info that I sent as it powers the LEDs from the power supply and not the board. Plus, it uses less pins than you latest design.
Here is a projecthub design for the toggle switch connection:

If your switch is in a matrix of switches then I can't see any way to have the switch light an LED. It can be done if you have one input pin per switch. Connect the LED between the input pin (anode) and Ground (cathode). Don't forget a series resistor to limit current. Then put a pull-down resistor from the input pin to Ground (yes, in parallel with the LED and current limiting resistor). One side of the switch goes to +5V. The other side to the input pin. When the switch is open, the pull-down resistor causes the input pin to read as LOW. When the switch is closed, the +5V causes the input pin to read as HIGH and powers the LED.

1 Like

my pots are on different circuits not same.Each pot has its own port on the micro. i looked at the design i see how its wired. I do have tx.rx free so i can put the landing gear just that on there. that way can power the leds.

I will just keep the landing gear switch on a different pin then,it will be much easier that way since no code plus i will endup with a extra pin left so that would work out.thanks this solves my problem.i will try this out and get back.

what value series resistor do i put in between the anode and ground.and what value pull down from input to ground ?

An easier way is the switch between pin and ground, with internal pull up enabled on the pin.
With the LED/resistor between VCC (5volt) and pin. That requires only one resistor.
Leo..

For a current limiting resistor, take the supply voltage and subtract the Forward Voltage Drop of the LED (guess 2.5V if you don't have the specs). Then divide by the desired current (figure 10 mA for most LEDs) to get resistance. 5V - 2.5V = 2.5V. 2.5V / 0.010A = 250 Ohms. A series resistor near 250 Ohms is a good guess in most 5V cases.

NOTE: If you have LEDs in series you have to add up the Forward Voltage Drops. You can't light up three LEDs in series if the combined forward voltage drop is 7.5V and your power supply is 5V. Give each LED its own current limiting resistor and put the three in parallel.

Pull-up and pull-down resistors are typically 10k Ohms. That will draw 0.5 mA at 5V.

is there some sort of diagram for this ? the last bit.led between vcc and pin is quite confusing. so the digital pin goes to the switch the other to the ground. Led+registor to vcc so wont the gnd/negative pin of the led go to the pin of the led ?

is this correct ?

Screenshot from 2021-07-21 18-55-17

It seems you have connected the switch to the TX pin...

Three LEDs in series is wishful thinking.
Most small red indicator LEDs have a Vf of about 1.8volt at low-ish current.
3 * 1.8volt = 5.4volt, and you need at least a volt for the current limiting resistor.
Two LEDs will just work, and they will draw 5volt - (2*1.8volt) / 220ohm = ~6mA.
Leo..

two leds wont work astehetically,so another solution i have come up with is i will have a extra usb connection that goes just to the led's have a step up converter in line.power the led's off of that.The tx pin is the only pin left unused so since its digital will just use it for signalling. I will be using green leds which usually have 2v so a 5v stepped up to 7v and leds in parallel should work correct ? 6v for leds + 1v for the resistor.

The switch can have as many LED strings as you want.
Two LEDs with a 220 ohm resistor, and a second string with one LED with a 470 ohm resistor could also work.
Leo..

That's ok, it's a Pro Micro.

That's a really inconvenient and completely unnecessary! Just connect your green LEDs in parallel, each with their own series resistor. If the current for the LEDs is being sourced/sunk by an Arduino pin, keep it below 30mA (10mA per led). But in your case it sounds like you are not sourcing/sinking the current through an Arduino pin? The current only passes through the toggle switch, and the Arduino pin is sensing the state of the switch?

1 Like

Screenshot from 2021-07-23 13-15-04

i guess this is appropriate ?

1 Like

i ran 3 leds in parallel off a single resistor(just for testing). i am not planning to do it that way just asking for science reasons what would happen if i continue doing this i guess damage ?

i couldnt get a led to work with 470 ohm,i had two on one string with 220 but the 470 in parallel single led didnt work idk why. i tried changing resistors but it didnt work.