#include
#define waterin P1_6
#define waterout P1_5
#define swim P1_7
bit flag;
char Count,t,waterinflag,wateroutflag,swimflag; // count for interrupt program
unsigned char second;
void Timeinit(void)
{
// Initialize the stopwatch
Count=0; t=0; second=0; flag=0;
// Start timer 1 and set it to working mode 2, so that the initial value of the timer is automatically loaded when the timer is interrupted
IE=0x8a; //Enable interrupts, select T0, T1 interrupts
TMOD=0x21; //Timer 0, use TR0 start mode, select working mode 1, timer 1, use TR1 start mode, working mode 2
TH1=0x06; //Set the initial timing value to 256-250=6 (250us, 40 times are required to achieve 10ms)
TL1=0x06;
TR1=1;
}
//Use T1 to time the stopwatch interrupt program, working mode 2
void Miao(void) interrupt 3
{
Count++;
if(Count==40){
Count=0;
t++; // hundredths of a second
if(t==100){
flag=1;
t=0;
if(second==10) second=0;
else second++;
}
}
}
void Initcover() { //Interrupt procedure of the cover
EA=1;
ET1=0;
EX1=1;
}
void coverinterrupt() interrupt 2 {
waterin=1;
waterout=1;
swim=1;
while (P3_3==0) ;
waterin=waterinflag;
waterout=wateroutflag;
swim=swimflag;
}
main() { //Washing machine working process
int i=0;
Initcover();
waterout=1;
wateroutflag=1;
swim=1;
swimflag=1;
P3_2=1;
if (P1_0==1) {
waterin=0;
waterinflag=0;
while(P3_2==1) {
waterin=1;
waterinflag=1;
for (i=0;i<10;i++) {
timeinit();
while (second!=10) {
swim=0;
swimflag=0;
if(flag) {
flag=0;
P1=~(second*2);
waterin=waterinflag;
waterout=wateroutflag;
swim=swimflag;
}
}
P1=0xff;
waterin=waterinflag;
waterout=wateroutflag;
swim=swimflag;
timeinit();
while (second!=3) {
swim=1;
swimflag=1;
if(flag) {
flag=0;
P1=~(second*2);
waterin=waterinflag;
waterout=wateroutflag;
swim=swimflag;
}
}
}
timeinit();
while (second!=10 ) {
waterout=0;
wateroutflag=0;
if(flag) {
flag=0;
P1=~(second*2);
waterin=waterinflag;
waterout=wateroutflag;
swim=swimflag;
}
}
waterout=1;
wateroutflag=1;
}
}
}}
Previous article:The microcontroller sends data to the PC
Next article:TLC2543 Driver (c51)
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
- [Job seeking] Xia Xian; Bachelor degree, 35 years old, graduated in Mechanical and Electrical Engineering; Looking for a job as a Mechanical Engineer
- CRC16 algorithm code for UDMA
- MSP430 ADC conversion + mean filter
- The functions of handheld devices realize information management in various industries
- Installation of the digital multimeter + RL78G14 development environment based on the serial port
- Simple LM317 adjustable power supply
- AC servo motor based on STSPIN32F0
- EEWORLD University - Designing wide input DC/DC converters for smart lock applications
- VS1053 module
- What is the temperature rise of a wire? How do you know the temperature rise of a wire?