The so-called "breathing light" is to control the flashing process of the LED light through a program, which has a rhythm like breathing and a gradual brightness change process.
First, here is a rendering:
This picture is a bit big...
This is what it looks like without any decoration, but after some simple decoration, it becomes something super cute.
Production process:
1 //******************************
2 // 51 MCU simulates breathing light
3 // 2012.9.23
4 // menglei
5 // p0.0 is connected to an LED light, state 0 is on
6 //******************************
7
8
9 #include
10 #define N 2 //Brightness and darkness rate
11 #define T 800 //PWM period
12 #define T1 1400
13 #define T2 900
14 //sbit led0=P0^0;
15 //======================
16 void pwm(int x)
17 {
18 while(x--);
19 }
20 //======================
twenty one
22 void flash1(void){
23 int t = 0;
24 char f = 0;
25 int count = 5; //5 times, the number of times each function is executed
26 while(1){
27 P0 = 0x00;
28 pwm(t); //Toff, light time
29 //led0=1;
30 P0 = 0xff;
31 pwm(T-t+100); //Ton, dark time
32 if(!f) t+=N+1; //The light rate is fast, simulating breathing
33 else t-=N; // dark rate is slower
34 if(t>T) {f=1;t=T;} //When the maximum value is exceeded, the maximum value is returned and the flag is dark.
35 if(t<0) {f=0;t=0;}//When the minimum value is exceeded, the minimum value is returned and the flag is lit
36 // count--;
37 }
38 }
39 void main()
40 {
41
42 while(1)
43 {
44 flash1();
45 }
46 }
There are not many programs, but the production of the circuit is indeed very time-consuming and brain-consuming, because you have to consider the routing of each line and can't make the line too complicated
This is the middle part, like a CRT TV, hahahaha
front:
The wiring during debugging: (disgusting)
Final production:
Previous article:The Principle and Implementation of 51 Single Chip Microcomputer Multitasking Operating System
Next article:The role of the header file INTRINS.H in Keil
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
- Why does the power consumption of stm32L0 increase after it enters STOP mode again after being woken up by an external interrupt in STOP mode?
- [TI millimeter wave radar evaluation]_4_boost board evaluation encountered problems 2
- Using registers to do STM8 UART1 error request help
- BearPi-HM Nano Development Board Review 0 Unboxing and Development Environment Setup
- Let's discuss how many people you think should be invited.
- Qinheng CH37X series interface chip application reference example
- I found another DK IOT STUDIO online IDE that runs RAPID IOT. I guess they are the same but distributed on different websites.
- ECG-based heart rate monitoring using the LaunchPad Value Line development kit for the MSP430G2452 microcontroller
- [GD32L233C-START Review] - VII. SPI mode driving 1.5-inch OLED screen
- My creative plan and functional implementation plan