MCU button start and stop led light program
#include
Void Delay(unsigned int t); sbit key=P3^2; // corresponding to the s19 button on the microcontroller development board
Void main (void)
{
While (1) / / after the function starts, it is always detecting whether the button is pressed
{
If(key==0) {
Unsigned char i; //Define an unsigned char type local variable i from 0 to 255
P0 = 0x7f; / / assign the initial value, the first light on the right lights up
For(i=0;i<8;i++) //Add a for loop, indicating that the program loop in the for loop is executed 8 times.
{
Delay (50000);
P0>>=1; // Move one bit to the right.
P0=P0|0x80; //After shifting right, the left end is automatically assigned 0, so the statement needs to be assigned 1
}
}
Else
{
P0=0x00;
}
} }
Void Delay(unsigned int t)
{
While(--t);
}
Single Passenger Lift,Hydraulic Passenger Lift,Passenger Lift Suppliers,Passenger Elevator Manufacturers
XI'AN TYPICAL ELEVATOR CO., LTD , https://www.chinaxiantypical.com