# Button box with light buttons

**URL:** <https://forum.arduino.cc/t/button-box-with-light-buttons/859884>\
**Category:** General Guidance\
**Created:** [May 10, 2021, 6:37am UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884 "2021-05-10T06:37:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [May 10, 2021, 6:37am UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/1 "2021-05-10T06:37:43Z")

</div>

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

[![](https://europe1.discourse-cdn.com/arduino/original/4X/1/7/f/17f4cf551de8ef16543cc766e1fd1ea1220eead5.jpeg "MAKE THIS BUTTON BOX | 32 FUNCTION w ENCODERS") ](https://www.youtube.com/watch?v=Z7Sc4MJ8RPM)

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:

> **[Thlevel 6Piezas 12mm Interruptor de Botón Autoblocante con LED Acero Inoxidable...](https://www.amazon.es/Thlevel-Interruptor-Autoblocante-Inoxidable-Impermeable/dp/B08F76111K)**
>
> Thlevel 6Piezas 12mm Interruptor de Botón Autoblocante con LED Acero Inoxidable Impermeable Interruptor de Botón de Encendido/Apagado 2A 12V/24V/125V/250V : Amazon.es: Otros Productos

And

> **[CESFONJER Luz LED Interruptor de Palanca SPST, Interruptor Basculantes 12V 20A...](https://www.amazon.es/KINYOOO-Interruptor-Basculantes-Instalar-Vehiculo/dp/B07KYRZ7H2)**
>
> CESFONJER Luz LED Interruptor de Palanca SPST, Interruptor Basculantes 12V 20A con Luz de LED y Tapa de Color para Instalar Vehiculo, Barco ect (Rojo 2 piezas, Amarillo 2 piezas, Blanco 2 unidades) : Amazon.es: Coche y moto

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

---

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [May 10, 2021, 12:16pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/2 "2021-05-10T12:16:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 10, 2021, 12:24pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/3 "2021-05-10T12:24:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [May 10, 2021, 12:28pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/4 "2021-05-10T12:28:52Z")

</div>

Hi,

> [@Assamita](#):
>
> 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.

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... 😀 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [May 10, 2021, 12:30pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/5 "2021-05-10T12:30:30Z")

</div>

Hi,  
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.. 😀 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 10, 2021, 12:35pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/6 "2021-05-10T12:35:57Z")

</div>

> [@Assamita](#):
>
> the brightness provided by 5V is more than enough

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

---

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [May 10, 2021, 2:37pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/9 "2021-05-10T14:37:59Z")

</div>

> [@TomGeorge](#):
>
> 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.

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

> [@PaulRB](#):
>
> When wiring toggle switches as a matrix, you must place a diode in series with each switch to avoid that problem.

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

> [@PaulRB](#):
>
> How will you wire all these LEDs? If you multiplex them, the brightness will drop further and may no longer be bright enough.

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.

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 10, 2021, 4:56pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/10 "2021-05-10T16:56:45Z")

</div>

> [@Assamita](#):
>
> Diodes have polarity. How should I solder them?

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.

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 10, 2021, 5:02pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/11 "2021-05-10T17:02:31Z")

</div>

> [@Assamita](#):
>
> 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

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?

---

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [May 10, 2021, 5:16pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/12 "2021-05-10T17:16:34Z")

</div>

> [@PaulRB](#):
>
> How many switches to you plan to have in your box?

Hi. This is what I'm working with:

 ![IMG20210510190915](https://europe1.discourse-cdn.com/arduino/original/4X/a/2/a/a2abea42c67bd397cb48ff14ae26c719575e80c5.jpeg)  
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?

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 10, 2021, 5:37pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/13 "2021-05-10T17:37:28Z")

</div>

So you have 20 buttons/switches and 4 LEDs?

> [@Assamita](#):
>
> 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?

Lost me there. Can you draw a schematic please?

---

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [May 10, 2021, 5:43pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/14 "2021-05-10T17:43:55Z")

</div>

> [@PaulRB](#):
>
> 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:

 ![Untitled](https://europe1.discourse-cdn.com/arduino/original/4X/8/3/6/83622ed83625e57589ef7bfec88332d6885ea9ff.png)

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 10, 2021, 6:01pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/15 "2021-05-10T18:01:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [May 10, 2021, 6:06pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/16 "2021-05-10T18:06:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 10, 2021, 6:13pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/17 "2021-05-10T18:13:24Z")

</div>

> [@Assamita](#):
>
> I am using a Lillypad USB...As soon as I can solder it and test it

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.

---

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [May 10, 2021, 6:28pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/18 "2021-05-10T18:28:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [May 11, 2021, 11:01am UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/19 "2021-05-11T11:01:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [May 11, 2021, 12:00pm UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/20 "2021-05-11T12:00:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pichoncin](https://avatars.discourse-cdn.com/v4/letter/p/bc8723/32.png) [@pichoncin](https://forum.arduino.cc/u/pichoncin)\
**Post date:** [August 13, 2021, 4:37am UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/21 "2021-08-13T04:37:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Assamita](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/assamita/32/1129187_2.png) [@Assamita](https://forum.arduino.cc/u/Assamita)\
**Post date:** [August 13, 2021, 9:48am UTC](https://forum.arduino.cc/t/button-box-with-light-buttons/859884/22 "2021-08-13T09:48:57Z")

</div>

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.

Saludos

[Next page](https://forum.arduino.cc/t/button-box-with-light-buttons/859884.md?page=2)
