Use stc89c52 microcontroller to control the air pump, with 2 working modes, the port can be modified by yourself
Reference address:Air pump control program based on 51 single chip microcomputer
#includesbit a=P1^5; // flashing light sbit b=P1^4; //air pump sbit c=P3^7; //status indicator light sbit ss1=P3^2; //One minute working mode sbit ss4=P3^3; //Four-minute working mode unsigned int q,w,e,r,y,u,i,n,m,l,h; csh(); // Initialize subroutine declaration ys(); //Delay subroutine ys2(); //Delay subroutine 2 declaration void main() { csh(); //initialization while(1) //Infinite loop number one { if(ss1==0){n=1;} //Determine the one-minute working mode and start the second cycle if(ss1==1){n=0;b=1;} //Determine if the one-minute working mode is to start the second cycle if(ss4==0){m=1;} //Determine the four-minute working mode and start the * cycle if(ss4==1){m=0;b=1;} //Determine if the four-minute working mode does not enable the * number cycle /*...........The following is a one-minute working mode...dividing line......................*/ while(n) //The second loop works for one minute. n is assigned a value of 1 and enters the loop body. { if(ss1==0) //Determine whether the one-minute working mode is enabled and execute the statement { for(l;l>0;l--); //delay judgment if(ss4==0){n=0;}//Determine whether the four-minute mode is enabled, disconnect the second loop and exit execution for(q;q>0;q--); //Delay determination q if(ss4==1) //Determine if the four-minute mode is not enabled and execute downward { if(q==0) //determine if q is reduced to 0 { b=1; //Disconnect the air pump w=1; //Loop body 2 w is 1 e=1; //Loop body 1 e is assigned to 1 } while(e) //Loop body number 3 { if(P3==0x7b) // Check if the indicator light and one minute start execution { while(w) //The initial value of w in loop No. 4 is 1 { ys(); // Half-second delay seems not allowed to be changed by yourself a=0; //The flashing light turns on r++;//Number of seconds plus 1 if(ss1==1) //Determine when the one-minute working mode is disconnected { ys2(); //Delay determination if(ss1==1) //One minute working mode is indeed disconnected {n=0;e=0;w=0;r=0;b=1;}//judgment is established, exit all } ys(); // Half-second delay seems not allowed to be changed by yourself a=1; // Flashing light off if(r==60) // Wait for the number of seconds to add to 60 before executing { w=0; //Disconnect loop body 2 r=60; //Keep the number of seconds equal to 60 b=0; //Start the water pump h=1; //Loop body No. 5 () while(h) //Loop body No. 5 if(ss1==1) //Determine that one minute has passed and the execution is down { ys2(); //Delay determination if(ss1==1) //After a delay, it is determined that the one-minute working mode is disconnected { b=1; //Disconnect the air pump n=0; //Exit loop number 2 e=0; //Exit loop body No. 4 r=0; //One minute time reset to zero while(1) { if(m==0); { h=0; break; } //Exit the fifth loop itself } }} } } } } }/*Judgment*/ }/*Loop body No. 2*/ }/*Loop body No. 1*/ /*..................The following is a four-minute working mode.......I am the dividing line...........*/ Download address of this program: http://www.51hei.com/ziliao/file/qibang.rar while(m) //The second loop works for one minute. n is assigned a value of 1 and enters the loop body. { if(ss4==0) //Determine whether the four-minute working mode is enabled and execute the statement { for(l;l>0;l--); //delay judgment if(ss1==0){m=0;}//Determine whether the one-minute mode is enabled, disconnect the second loop body and exit execution for(q;q>0;q--); //Delay determination q if(ss1==1) //Determine if the one-minute mode is not enabled and execute downward { if(q==0) //determine if q is reduced to 0 { b=1; //Disconnect the air pump w=1; //Loop body 2 w is 1 e=1; //Loop body 1 e is assigned to 1 } while(e) //Loop body number 3 { if(P3==0x77) // Check the indicator light and the four-minute start to execute the following { while(w) //The initial value of w in loop No. 4 is 1 { ys(); // Half-second delay seems not allowed to be changed by yourself a=0; //The flashing light turns on r++;//Number of seconds plus 1 if(ss4==1) //Determine when the four-minute working mode is disconnected { ys2(); //Delay determination if(ss4==1) //The four-minute working mode is indeed disconnected {m=0;e=0;w=0;r=0;b=1;}//judgment is established, exit all } ys(); // Half-second delay seems not allowed to be changed by yourself a=1; // Flashing light off if(r==240) // Wait for the number of seconds to add to 240 before executing { w=0; //Disconnect loop body 2 r=240; //Keep the number of seconds equal to 240 b=0; //Start the water pump h=1; //Loop body No. 5 () while(h) //Loop body No. 5 if(ss4==1) //Determine that the execution will exit after four minutes { ys2(); //Delay determination if(ss4==1) //After the delay, it is determined that the four-minute working mode is disconnected { b=1; //Disconnect the air pump n=0; //Exit loop number 2 e=0; //Exit loop body No. 4 r=0; //Four minutes time reset to zero q=60000; while(1) { if(n==0); { h=0; //Exit loop body No. 5 break; //Exit the loop } } } } } } }/*Judgement*/ }/*Loop body No. 2*/ }/*Loop body No. 1*/}}}} /*.......................Initialization subroutine........................................*/ csh() // Initialize subroutine { a=1; //The flashing light does not flash b=1; //The air pump is not turned on c=0; //status indicator lights up ss1=1; //One minute working mode is not started ss4=1; //Four-minute working mode is not started r=0; //One minute and 60 seconds e=0; // loop body e is assigned to 1 q=60000; //First delay determination q initial value l=60000; //delay h=0; //Loop body No. 5 } ys() { for(y=23;y>0;y--) for(u=152;u>0;u--) for(i=70;i>0;i--); //It seems that you are not allowed to change the half-second delay } ys2() { for(y=167;y>0;y--) for(u=171;u>0;u--) for(i=16 ;i>0;i--); }
Previous article:Super multifunctional electronic clock program
Next article:The microcontroller key is turned on only when the specified time is reached
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- 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)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Guess you like
- CC26xx BLE adds characteristic value of indication attribute
- Answer the questions to win prizes | Shijian Exploration: Smoke detection empowers smart buildings
- Todd Gillenwater talks about why he is optimistic about UWB technology
- Embedded Linux boutique resources, with source code comments
- Does anyone have the component library and PCB package library of POWER PCB 5.0? Please share
- Looking to buy C8051F video?
- Free review: HuaDa M4 core HC32F460 board, #all serial communication ports, GPIO can be freely mapped# Is it fresh?
- Playing with Zynq Serial 13 - Using GIT for project backup and version management 5
- IGBT drive circuit
- Comparison of 4G and 5G wireless technology details