#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
sbit key = P3^2;
sbit led = P1^0;
void delay(unsigned int y)
{
unsigned int x,z;
for(x=y; x>0; x--)
for(z=110; z>0; z--);
}
void main (void)
{
led = 1;
while (1)
{
if (key == 0)
{
delay(10);
if (key == 0)
led = ~led;
}
while(!key);
}
}
|