LED Light
LED stands for semiconductor light emitting diode, which is made of semiconductor materials. It is a light-emitting device that directly converts electrical energy into light energy and electrical signals into light signals. It has the characteristics of low power consumption, high brightness, bright colors, vibration resistance, long life (normal light emission time is 80,000-100,000 hours), cold light source, etc. It is a real "green lighting". Actual picture:
The symbol of LED in the circuit diagram is:
It has the basic characteristics of a diode, that is, it conducts in the forward direction and is cut off in the reverse direction. To light up the LED, an operating current needs to flow in the forward direction.
The operating voltage drop of different LED lights is different. The operating voltage drop range of ordinary light-emitting diodes is: 1.6-2.1V. The operating current is: 1-20mA.
Light up the LED in the microcontroller
Schematic diagram of LED module in single chip microcomputer:
By observing the circuit schematic, it can be concluded that to light up the small LED light on the development board, you only need to control the P2 port to output a low level (that is, assign a value of "0" to the P2 port).
1. Light up all LED lights on the microcontroller
code show as below:
#include sbit LED1 = P2^0; sbit LED2 = P2^1; sbit LED3 = P2^2; sbit LED4 = P2^3; sbit LED5 = P2^4; sbit LED6 = P2^5; sbit LED7 = P2^6; sbit LED8 = P2^7; void main() { LED1 = 0; LED2 = 0; LED3 = 0; LED4 = 0; LED5 = 0; LED6 = 0; LED7 = 0; LED8 = 0; } The results are as follows: 2. The LED light flashes Code: #include unsigned int i; void main() { while(1) { P2 = 0; i = 65535; while(i--); P2 = 0xff; i = 65535; while(i--); } } 3. Flowing lights Code: #include #include #define uint unsigned int #define uchar unsigned char uchar temp; void delay(uint z) { uint x,y; for(x = z;x > 0;x--) for(y = 114;y > 0;y--) } void main() { temp = 0xfe; P2 = temp; delay(100); while(1) { temp = _crol_(temp, 1); P2 = temp; delay(100); } }
Previous article:51 MCU Self-study Notes (V) - Buzzer
Next article:51 MCU Self-study Notes (Part 3) - Basics of Electronic Circuits
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications