Privacy statement: Your privacy is very important to Us. Our company promises not to disclose your personal information to any external company with out your explicit permission.
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);
}
September 29, 2024
October 30, 2024
البريد الإلكتروني لهذا المورد
September 29, 2024
October 30, 2024
Privacy statement: Your privacy is very important to Us. Our company promises not to disclose your personal information to any external company with out your explicit permission.
Fill in more information so that we can get in touch with you faster
Privacy statement: Your privacy is very important to Us. Our company promises not to disclose your personal information to any external company with out your explicit permission.