学习记录1:按下按键灯亮,松开按键灯灭
作者:互联网
单片机SC95F8617
//LED :P06
#include "SC95F861x_C.H"
sbit LED1=P0^6;
sbit k1=P0^3;
void delay(unsigned long time)
{
while(time>0){
time--;
}
}
void Ioinit()
{
P0CON=0x40;//MOV P0CON,#40H
P0PH=0xFF;//MOV P0PH,#3FH
}
void main()
{
Ioinit();
while(1){
if(k1==0){
delay(1000);
if(k1==0){ //去抖之后再次判断
//delay(1000);
LED1=0;
}
if(k1==1){
//delay(1000);
LED1=1;
}
}
}
}
学习记录,仅供参考
标签:LED1,灯亮,灯灭,void,time,delay,k1,按键,1000 来源: https://blog.csdn.net/qq_48701278/article/details/115708306