Here as I have to write code (led only after the simulation running water, and cannot achieve button control led and water) :
# include "reg52. H"//this file defines the MCU some special function register
# include
//to use move function, so join the header file
typedef unsigned int u16;//to statement defines the data type
Typedef unsigned char u8;
# define led P1
Sbit k1=p3 ^ 0;
U8 a;
Void delay (under-16 I)
{
While (I -);
}
Void main ()
{
u8 i;
Led=0 xfe;
Delay (50000);//about 450 ms delay
While (1)
{
If (k1==0)
{
delay(1000);
If (k1==0)
{
A=~ a;
}
}
If (a==0)
{
for(i=0; i<7. I++)
{
Led, led=_crol_ (1);
Delay (50000);//about 450 ms delay
}
}
If (a==1)
{
for(i=0; i<7. I++)
{
Led, led=_cror_ (1);
Delay (50000);//about 450 ms delay
}
}
}
}
CodePudding user response: