Make ordinary buttons light up with backlight action.
Video address: https://www.bilibili.com/video/BV1wT411V7GV
makes ordinary buttons light up with backlight action_bilibili_bilibili
buttons, as a basic input device in the microcontroller circuit, we generally only care about Regarding its input function and key circuit structure, few people think of adding a backlight to it.
Keys with backlight are sold on the market. Keys with backlight are common, such as mechanical keyboards. Generally, these have the backlight position reserved in the mechanical structure, but the price is many times that of ordinary buttons. Conventional buttons, which do not have backlight positions, are generally solid, so it is difficult to add a backlight.
This is the backlight I added to the ordinary buttons.



The buttons are ordinary 6*6*7 buttons, and I also added key caps. As for the backlight, it uses 0805 packaged LED, which is mounted on the back of the board. Use a 0603 packaged resistor for current limiting. The resistor value is 470R, which is considered a small resistance value. I usually use a 10K resistance value. The purpose of using a smaller resistor here is to obtain greater LED brightness. After all, the direct part of the LED is blocked by the button and needs to be diffused through the inner layer of the PCB. Because the PCB board is yellow, the color of the LED will be mixed, with some color cast.

As for the actual test results, I am still very satisfied. The circuit diagram is also very simple. Just connect the negative electrode of the LED to the IO port, the positive electrode to the current limiting resistor, and then connect it to VCC. This kind of connection requires additional IO ports to light up the LED. Of course, there is also a new question. Will it affect button detection?
This connection method will not affect the button detection. In fact, the LED and the resistor together form a new "pull-up resistor." When the button is pressed, the LED will light up and does not affect the IO turning to low level.

If you want to press the button once and change the lighting state of the LED, this can also be achieved. What the code below implements is that when the button is pressed once, the backlight goes out, and when pressed again, the backlight turns on. Does not affect key detection.
Can other effects be achieved? You can try this yourself, such as breathing backlight. As long as the key detection code is scanned, it will not affect the key detection.
Now that we have the circuit diagram, how do we draw the PCB?
The packaging of the buttons is conventional, but what about the backlight LED?
The backlight LED uses a reverse-mounted package, which is the package I tested before. Modified using 0805LED package. The important parameters of the package are shown in the figure below.
Both pads are 1*1.4mm, and the slot in the middle is a square with a side length of 1.524mm.

If you draw it according to the above dimensions, it can be drawn. Of course, if you are lazy, you can search in LCEDA and find the device I drew to use. The dotted end of the LED package represents the positive terminal.

Then, after the LED packaging is completed, there will definitely be some problems.
For example, why use 0805 instead of 0603? Isn't the 0603LED smaller? This is also because it is smaller and the holes drilled are not guaranteed, so it is not used. The 1206 package LED is a bit big.
Can LEDs attached to the back be teppanyaki? I haven't tried this, I soldered it with a soldering iron.

After obtaining the back-mounted LED package, we drew the circuit diagram and came to the PCB part.

We see that on the PCB, the yellow color is the exposed pad, and the yellowish gray color is the PCB board. This is the effect of copper-free windows. There are copper windows that are solder pads and will not let light through.
First, to achieve no copper laying in this area, it is necessary to set up a prohibited copper laying area, and then set up a window opening area. The specific operation is as follows:
use the solid fill in the PCB tool, draw a rectangle on the top layer, and then change the rectangle to no fill. You can explore the size of the rectangle yourself.
Then select the rectangle just now, copy it, and select the reference point as the upper left corner of the rectangle. After copying, CTRL+V to the PCB, overlapping with the prohibited copper area, and then click to select. Only one can be selected at a time. We just need to select one. Then on the back side, first change it to full filling, and then change it to top layer solder mask. area.
In order to avoid short circuits, try not to route wires in the window area, and run wires that need to be routed on the back.
Notes:
1. There should be a certain distance between the window opening areas to prevent the backlight from spreading to the surroundings.
2. The actual produced LED holes may be irregular, but after my test, the LED can be plugged in. It is not recommended to change the package size of the back-mounted LED.
3. There is no silk screen in the window area. You can see the actual PCB for this. Therefore, if you want to write the silk screen of the button function, avoid it in the window area. If it appears, it will be cut off by the PCB board manufacturing engineer.
4. In order to avoid being so complicated every time you draw, you can make the keys and backlight into a package and call it directly later.
Conclusion
After adding lights to the buttons, there will be more effects, such as adding backlight to ordinary matrix buttons, and the backlight diffusion effect will be achieved when the button is pressed. For example, the screen prompts, please press the illuminated button, etc. There can be many applications.