Ev> Blog> Discussion on Programming of LED Light-emitting Diode in Single Chip Microcomputer

Discussion on Programming of LED Light-emitting Diode in Single Chip Microcomputer

March 04, 2022

   Abstract: A single-chip microcomputer is one of the most used CPU devices, and the use of light-emitting diodes is the most commonly used device for single-chip microcomputers. This paper introduces and summarizes the working principle and the most common programming methods of LEDs, and gives a complete program.

0 Preface

Due to its small size, low price, strong function, high reliability, control and low price, the single-chip microcomputer has not only become an intelligent control tool used in the field of industrial measurement and control, but also has penetrated into every corner of people's work and life. In the engineering school, the course "Single-chip principle and application" is basically opened, and for all those who learn MCU, the most important thing is to control the LED of the LED.

1 How the light-emitting diode works

LED Light- Emitting Diode is abbreviated as LED, a diode made of a compound of gallium (Ga) and arsenic (As) or phosphorus (P). Like ordinary diodes, LEDs consist of a PN junction and also have unidirectional conductivity. When a forward voltage is applied to the light-emitting diode, holes injected from the P region into the N region and electrons injected into the P region from the N region are separated from the electrons of the N region and the P region by a few micrometers in the vicinity of the PN junction. The hole complexes, which produce the fluorescence of spontaneous radiation, and can therefore be used to make light-emitting diodes. Used as an indicator light in circuits and instruments, or as a text or digital display. The gallium arsenide diode emits red light, the gallium phosphide diode emits green light, and the silicon carbide diode emits yellow light.

The LED can only be turned on in one direction, and the reverse breakdown voltage of the LED is about 5 volts. Its forward volt-ampere characteristic curve is very steep. In use, a current limiting resistor must be connected in series to control the current through the tube to control the brightness of the LED. The current limiting resistor R can be calculated by:

R=(E-UF)/IF

Where E is the supply voltage, UF is the forward voltage drop of the LED, and IF is the general operating current of the LED.

2 LED programming method

Assume that the connection circuit diagram of the LED is shown in Figure 1. The eight red LEDs are respectively connected to the 8 pins of the P1 port of the MCU through the current limiting resistor. The MCU selects AT89C51.

2.1 Control of a single LED

Single LED control

In Figure 1, as shown in the figure, if LED D1 is to be lit, since the positive pole of D1 is connected to the power supply VCC through resistor R1, then D1 must be forwarded to make the cathode of D1 low, that is, The P1.0 pin is low. This can be controlled by software. The complete C51 program is as follows:

Complete C51 program

Similarly, if the LED D1 is to be blinking and blinking, the working principle is to let D1 light up and delay for a period of time, then let D1 go out and delay for a period of time and continuously cycle, so that you can observe D1 flashes and blinks. The delay can be either software delay or timing counter timing delay. This paper uses software delay. The working principle is that each instruction requires a certain clock cycle to run. A certain number of clock cycles can be used to achieve delay. Function, the crystal oscillator in this figure is 12MHz, then the 12 oscillation period is 1us, and the delay program of delay 1ms is as follows:

Delay 1ms delay program

Delay 1ms delay program

The control LED D1 flashes and blinks completely. The C51 program is as follows:

Control LED D1 blinks and flashes completely C51 program

2.2 Control of multiple LEDs

The control principle of multiple LEDs is the same as that of a single LED. In Figure 1, if you want to control the blinking of 8 LEDs at the same time, you only need to make 8 LEDs at the same time. The lighting delays for a period of time, and at the same time, the 8 LEDs are turned off and delayed for a period of time. After repeated cycles, 8 LEDs can be flashed continuously. The complete C51 program is as follows:

8 LEDs flashing continuously, complete C51 program

8 LEDs flashing continuously, complete C51 program

In Figure 1, if you want to control 8 LEDs D1, D3, D5, D7 odd lights and D2, D4, D6, D8 even number alternately flash, you only need to send the value of the corresponding status of 8 LEDs connected to P1 port. This function can be implemented with the P1 port and delay. The complete procedure is as follows:

Complete program

2.3 Control of the flow lamp

For the pattern water light, the working principle is the same as that of the previous multiple LEDs. It only needs to send the value of the corresponding port of the lamp in different states to the corresponding control port and delay it for a certain period of time. Therefore, the port value of the corresponding state is stored in an array, and the value of the array is taken cyclically, and each time a value is delayed for a period of time, that is, the program is omitted.

3 Summary

MCU is used more and more in various industries. The paper summarizes the use and programming methods of LEDs in MCU, and gives the working principle and complete program of various methods.

2 times
Window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": false, "bdPic": "", "bdStyle": " 0", "bdSize": "24" }, "share": {}, "image": { "viewList": ["qzone", "tsina", "tqq", "renren", "weixin"], "viewText": "Share to:", "viewSize": "16" }, "selectShare": { "bdContainerClass": null, "bdSelectMiniList": ["qzone", "tsina", "tqq", "renren" , "weixin"] } }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share. Baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];
Contal ABD

Yazar:

Mr. Huang Yiyu

E-posta:

sales@xigeled.cn

Phone/WhatsApp:

+8613751262319

Popüler Ürünler
Blog Haberleri
Ayrıca sevebilirsiniz
İlgili Kategoriler

Bu tedarikçi için e-posta

Konu:
E-posta:
İleti:

Mesajınız MSS

Contal ABD

Yazar:

Mr. Huang Yiyu

E-posta:

sales@xigeled.cn

Phone/WhatsApp:

+8613751262319

Popüler Ürünler
Blog Haberleri
Dongguan XINYUDA Technology Co., Ltd. Dongguan Xinyuda Technology Co., Ltd., 1990'larda LED Ar -Ge ve Yatırım'a odaklanarak Hong Kong Konlida International Group Co., Ltd. tarafından Hong Kong'da kurulmuştur. On yıldan fazla...

Bültenimize abone olun

  • Mobile-Phone
    +8613751262319
  • Adres
    Room 202, Building 4, No. 3, East Siheng Road, Lianhu, Tangxia Town, Dongguan, Guangdong China
We will contact you immediately

Fill in more information so that we can get in touch with you faster

Privacy statement: Your privacy is very important to Us. Our company promises not to disclose your personal information to any external company with out your explicit permission.

Gönder