#include "stc8a.h"
#include "delay.h" //引入延时函数头文件
#define LED P55
#define K2 P52
#define K3 P53
//author: fxf
//date: 2021-11-17
void main()
{
LED=1; //初始化,LED熄灭
while(1)
{
if(K2==0) //判断按键按下
{
Delaynms(10); //防抖
if(K2==0)
{
LED = ~LED; //取反
}
while(!K2); //松键检测:检验到按键有变化才进行下一步循环
}
}
}
#include "stc8a.h"
#include "delay.h" //引入延时函数头文件
#define LED P55
#define K2 P52
#define K3 P53
//author: fxf
//date: 2021-11-17
void main()
{
LED=1; //初始化,LED熄灭
while(1)
{
if(K2==0) //判断按键按下
{
Delaynms(10); //防抖
if(K2==0)
{
LED = ~LED; //取反
}
while(!K2); //松键检测:检验到按键有变化才进行下一步循环
}
}
}
举报