单片机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;
}
}
}
}
学习记录,仅供参考