Button box with light buttons

Hi. I'm working on doing a simracing button box similar to this one:

The main difference being that I'm using some LED buttons that should light only when they are pushed/on. The buttons I'm using are:
How should the wiring be so they light up when turned on and don't fry the arduino?

(BTW, I've checked and though they are rated for 12V, the brightness provided by 5V is more than enough)

Thank you

Also, seems like the matrix method doesn't properly work with buttons that latch, like the first switch in the video, as when some of them are on, it causes pressing other buttons to read multiple values (probably because they are being bridged). I'll try to upload a video afterwards to explain what I mean.

When wiring toggle switches as a matrix, you must place a diode in series with each switch to avoid that problem.

1 Like


Are you sure that the original design uses latching switches, I think you will find it uses momentary press buttons.
They do not latch on, the software needs to see only one switch on at a time to detect it in the matrix.

Tom... :grinning: :+1: :coffee: :australia:

Look at the video and the parts list underneath it.

ZHAOYAO AC 250V 3A OFF (ON) Momentary Push Button Switches - Black, Green (5 PCS)

Momentary press buttons and momentary toggle switches.

Toggle Flick Switch DC (ON) OFF Momentary Car Dash Light Metal 12V-110V-250V

These are the descriptions form the YouTube links.

Tom.. :grinning: :+1: :coffee: :australia:

How will you wire all these LEDs? If you multiplex them, the brightness will drop further and may no longer be bright enough.

Loot at the moment he tests it. The first one with the lid latches, and only turns off when he lowers the lid.

Thank you. That makes sense. Diodes have polarity. How should I solder them? I'll do some testing.

Well, I'm not too concerned about the brightness because it's only a max of 5 leds that should not draw more than 100mah (and it's even probably less because 3 of them are rated for 12/24V so the resistors are probably overrated for 5V). I'm more concerned about how should I wire them, as I'm not sure how to.

How will you scan your matrix of switches? Using standard Arduino "keypad" library? If so, the "row" pins are set by the library to INPUT_PULLUP and the column pins are set to OUTPUT, LOW during the scan. So your diodes + switches need to have their anodes connected to row pins and cathodes to column pins. Does not matter whether you connect the anode of each diode to the switch or the cathode.

One possibility is to use the LEDs in the switches as the diodes, so no extra diodes are needed. But I am sure that the leds will be very dim if used this way and probably not visible at all. The keypad library only scans each column very briefly during each scan, and the internal pull-up resistors are very high, around 40~50K.

You will be concerned if they are too dim to see! The problem here is not the instantaneous current draw, it is the average current draw. If you multiplex the leds, you lower the average current to a fraction of the instantaneous current. That will result in considerable dimming. And that's in addition to the fact you mentioned: the series resistors build into the switches were chosen for 12V supply, not 5V. The combination of these 2 factors could result in very dim leds.

How many switches to you plan to have in your box?

Hi. This is what I'm working with:

The two covered switches have a built in 5V LED. The two buttons below them are latch push buttons also with LEDs.
I've thought of using a matrix for all the buttons in the right + the Engine start/stop button (if the diode thing works), and then simply link the other 4 switches/buttons to individual pins of the arduino. If I connect the VIN pin to the + of the inbuilt LED, the ground to one of the legs, and a digital pin to the other, shouldn't it provide 5V when turned on, as well as read HIGH in that D pin?

So you have 20 buttons/switches and 4 LEDs?

Lost me there. Can you draw a schematic please?

No wonder, I lost myself!! LOL I think I didn't say it correctly.

An image is worth a thousand words:

Ok, I get it. Yes, you can use like that but you will also need a pull-down resistor between the Arduino pin and ground, e.g. 10K. Unless you are using a type of Arduino that has built-in pull-down resistors. Most types do not have them, but some of the more modern types like Arduino Zero might have them.

I am using a Lillypad USB, so I'll add that pulldown. Thank you for the advice. As soon as I can solder it and test it I'll let you know.

I do not think you are ready to solder anything. You need to finalise a schematic and post it here so we can check it. Then build a prototype on breadboard. Lillypad has only 9 I/o pins, not enough for your circuit, and is not breadboard compatible. I would recommend a Pro Micro (do not confuse with Pro Mini) which has more pins and is breadboard compatible.

Well, it's actually a pro micro knockoff, with all its pins and shape (almost, it doesn't have the exact same measures). But it needs to be programmed as a lillypad

It worked :slight_smile: and the leds are bright enough, even with all 5 of them lit at the same time.

Good. I was only worried about the LEDs being bright enough if you were multiplexing them, but you are not.

Hola buenos dĂ­as

PodrĂ­as poner imagen para verlo?
O la programaciĂłn para ver como se hace?
Te lo agradecería por que estoy intentando hacerlo también e intentando solucionar lo de los botones que se quedan comunicados
Muchas gracias

Hola pichoncĂ­n.
No puedo enseñarte una foto porque no era para mí la botonera, ya no la tengo, pero es muy sencillo.
En cuanto a programación, no hay ninguna diferencia. Para solucionar el problema de que se queden los botones encendidos lo que tienes que hacer es colocar un diodo en uno de los bornes del interruptor. Concretamente los míos son interruptores de 3 pines, pues le coloqué un diodo a cada uno en el pin central.