Controll LEDs with button box

Hey, I'm completely new to arduino and microelectronics.
I'm currently trying to build a button box for Simracing and Simflying
(so it's a game controller) using a 5x4 button matrix and three extra toggle switches. I also use 10 LEDs

So each of the 3 toggle switches outside of the button matrix should iluminate one each LED.

One toggle switch wich is included in the button matrix should light 3 LEDs.

3 toggle switches included in the button matrix should also control 1 LED each.

Plus one Pushbutton included in the matrix should activate one LED wich should keep on and should turn off once the button is pushed again.

Im using the arduino nano but I'm currently thinking about changing to a arduino pro micro.

How do I wire the LEDs and how do I need to code it?
Thanks for any help

Search "buttonbox" ... This bottonbox seems complete... and can be used as an example.

No need to think about it. Pro Micro is suitable. Nano is not suitable (assuming you mean classic Nano V3).

Can I ask if you are planning to contribute to the project? :grin:

Why are some outside the matrix?

I suggest using DPDT toggle switches. You can wire one side to the matrix and the other side to the LEDs. This will help minimise the Arduino pins needed and keep the code simpler.

You will need to connect a small diode in series with each button/switch in the matrix, because there are some toggle switches in the matrix.

2 Likes

Thank you for your help, I'm gonna switch to pro micro then.

Some buttons are outside of the matrix because I don't know if it's possible to do a non square matrix I don't really know how to describe it🥲.

So I can just wire the LEDs in row with a switch inside of the matrix?
How high is the voltage output of the pro micro on a digital pin? Is that enough to illuminate a 3V LED

Yes, the diodes will be part of the plan.
I will send my shemetic once it's finished.

That video actually gave me the idea of building a buttonbox, I just changed the incoders to toggle switches and added some more buttons and LEDs

You are already considering a non-square matrix!

5x5 or 4x4 would be square...

If you make your matrix 6x4 or 5x5 you will have room for your 3 other toggle switches. You do not have to use every position in the matrix if you don't need them all.

Like I said, it's easy if you use DPDT (or DPST) toggle switches. The "DP" part of the description means "double pole" and indicates that the switch is actually 2-switches-in-1, connected together mechanically, but not electrically. You can use one switch for the matrix and the other switch to light the LEDs.

You can connect LEDs in a row physically, sure. You won't be able to connect 3 in series, electrically speaking, you will probably need to connect them in parallel, which means each led will need it's own current-limiting resistor.

Pro Micro are available in 5V and 3.3V versions. I suggest using 5V version for your project.

1 Like

That's what I tried to ask, thank you.
Do the pins constantly put out the 5V?

No, that would make them useless for any project. They are very flexible and can put out 5V or 0V or neither, or pulses with different frequencies and duty cycles, or they can be pulled up weakly to 5V, or output data as pulses, or receive data, or receive analog voltages, under control of your code, and as is needed for whatever project you are doing.

For the matrix, some will be acting as weakly pulled up (to 5V) inputs. Others will output 5V, but one will output 0V at any moment, and they will take turns which pin outputs 0V. This way, the matrix can be scanned to figure out which buttons are pressed and what position the toggle switches are in.

1 Like

So if I were to put some LED in row with a switch inside of the matrix it would basically go on and off really fast?

You can't do that, it would prevent the Arduino from reading the matrix.

I'll say it one last time, DPDT/DPST toggle switches would enable you to use the same switch inside the matrix and outside the matrix to control the LEDs.

1 Like

Alright, thank you now I know all I need to know

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.