这个简单,但是你没有按键的啊,你上面的按键是单片机复位用的啊,你必须在单片机P1.1端口在接个按键,我帮你写过程序啊!
/*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
**/
#include "REG52.H"
sbit LED1_INPUT = P1^0;
sbit KEY1_INTPT = P3^4;
void Delay_1ms(unsigned int Cnt)
{
unsigned int x, y;
for(x = Cnt; x > 0; x--)
for(y = 120; y > 0; y--);
}
int main(void)
{
P0 = 0xFF;
P1 = 0xFF;
P2 = 0xFF;
P3 = 0xFF;
while(1)
{
if(KEY1_INTPT == 0)
{
Delay_1ms(10);
if(KEY1_INTPT == 0)
{
LED1_INPUT = ~LED1_INPUT;
}
while(KEY1_INTPT == 0);
}
}
}
#include
sbit sw=xxx;(按键对应的端口,目测,图中未标示)
sbit led=P1^0;
viod main()
{
led=sw(也可能是led=~sw,另外按键消抖省略)
}