Light up the LED light
1. What is LED
The full name of LED is semiconductor light-emitting diode. It is made of semiconductor materials and is a light-emitting device that directly converts electrical energy into light energy and electrical signal into optical signal. It is characterized by low power consumption, high brightness, bright colors, vibration, and long life. It has the advantages of long life (80,000-100,000 hours of normal light emission) and cold light source, making it a true "green lighting".
2. LED working parameters
The symbol of LED (Light Emitting Diode) in the circuit diagram is:
It has the basic characteristics of a diode: forward conduction and reverse blocking. To light up the LED, operating current needs to flow from the forward direction.
The working voltage drop of ordinary light-emitting diodes is: 1.6~2.1V.
Working current: 1~20mA.
With the passing current of the LED in the picture, we can follow Ohm's law I (current) = U (voltage) / R (resistance)
It can be calculated as 3mA.
3. Schematic analysis
4. C language knowledge
Keywords: sbit
Function: bit definition
General format: sbit identifier = address value;
For example: sbit LED1 = P1^0;
Note: The "P" in P1 in the address value must be a capital P
5. Write code
1. Turn on LED1
#include sbit LED1 = P1^0; // P must be uppercase to control the red light void main(){ // After the program is compiled, the main function itself will loop LED1 = 0; // When set to 0, input a low level and the first light of the microcontroller will light up. // LED1 = 1; // When set to 1, input a high level, the first light of the microcontroller will go out } Rendering: 2. Turn on LED1, 3, 5, and 7, and turn off LED2, 4, 6, and 8; #include void main(){ // main function itself will loop while(1){ // Generally, when executing a program, you need to write a while loop body to execute the code. P1 = 0XAA; // 1010 1010 // Make LED1, 3, 5, 7 light up } } Rendering:
Previous article:Light up the LED light (STC89C52RC chip)
Next article:ISIS 7 Professional Simulation - Keyed Water Lamp
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- C2000 MCU Boot Process Analysis - Taking TMS320F28069 as an Example
- Analysis and calculation of UART module register configuration in MSP430FR2311
- [New Year's Flavor Competition] + Show off your New Year's Eve dinner and experience ice and snow tourism in the north!
- In STM32F103RCT6, I use the state machine method to add buttons, but I don't want the buttons to work in a function.
- [2022 Digi-Key Innovation Design Competition] Revised version of 2-DOF pan-tilt robot control platform
- Please recommend a heartbeat sensor chip!
- Selling a brand new STM32F412 development board
- Award-winning review: Sensirion SEK-SVM40 is coming in the new year, easily monitor indoor air quality and test whether it is "good luck"
- [Domestic digital isolation chip replacement] Nanochip MSI series replaces ADI ADUM and TI IOS series isolation chips
- Is it really useful to use a 0 ohm resistor to separate the digital ground and analog ground?