Using LEDs to create a Cupid’s arrow pattern with different dot matrix variations seems like a good idea.The romance of electronic engineers does not depend on how perfect the finished product is, but rather on the difficulties in the implementation process.
Cupid’s arrow
The small board below integrates 40 LEDs to form the Cupid’s arrow pattern. The difficulty lies in that these 40 LEDs are controlled by only five IO ports of an eight-pin MCU to light up each LED. Alert students will immediately think that there is a significant challenge in this.
Using an eight-pin MCU to control an electronic project composed of 24 LEDs forming Cupid’s arrow
If using one IO port, you can control one LED to light up or turn off through high and low levels. Two IO ports can control two LEDs, and so on. If assisted by auxiliary circuits, it is possible to control four LEDs with two IO ports. Below is an example:
Two pins control four LEDs
If there are some doubts about the above circuit, you can refer to the truth table below to analyze the voltage of pins P1, P2, and PR1 in the circuit, as well as the corresponding LED lighting based on their combinations.The voltage of P1 and P2 determines the voltage of PR1 and which LED lights upWith two IO ports, it can provide=4 states, which can control the number of LEDs and their state combinations.In the previous circuit, there are a total of 40 LEDs, while the used IO ports are only 5, and the high and low level state combinations are only=32 states. So how does it control the lighting states of 40 LEDs?This brings us to a method called Gugaplexing for multiplexing MCU IO ports. For MCU IO ports, there are actually three states: high (H), low (L), and high impedance (Z). In high impedance state, the MCU IO port is almost disconnected from the outside.In the above circuit where two IO ports control four LEDs, in addition to the four states mentioned earlier, there is a fifth state where both IO ports are in high impedance state, at which time L3 and L4 are not lit. If this state is applied, it is possible to continue increasing the number of controllable LEDs.Below is the circuit diagram showing how to use four IO ports to control 24 LEDs.Using four IO pins to control 24 LEDsIndeed, it looks a bit brain-burning. But if you understand the previous two IO ports controlling four LEDs circuit, combined with the following two tables, you will understand the principle.Anyway, I have read it many times and finally understood the mysterious principle. This puzzle is left for curious students to analyze themselves.
The relationship between P1, P2, P3, P4 and the LEDs
Using the Gugaplexing method to control LEDs, you can use N IO ports to control LEDs. Therefore, if there are five IO ports, you can control 40 LEDs, and the principle is the same as the above four IO ports controlling 24 LEDs.Seeing this, one will feel the impulse to design and draw the circuit diagram.
Author: Zhuoqing, Source: TsinghuaJoking
Statement: This article is reproduced with permission from the “TsinghuaJoking” public account. The reproduction is for learning reference only and does not represent this account’s endorsement of its views. This account does not bear any infringement responsibility for its content, text, or images.
END♥Click👇the business card, follow me♥Previous Recommendations1. Huawei genius boy typed a character in 108 days, redefining customized keyboards2. Disassembling a Chinese-made “Raspberry Pi” development notebook, is the price of $279 worth it?3. Domestic replacement MCU pitfalls