#include <reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
sbit key=P2^2;
sbit led=P3^2;
void delay(u16 i)
{
while(i--);
}
void keypr()
{
if(key==0)
{
delay();
if (key==0)
{
led=~led;
}
while(!key):
}
}
void main()
{
led=0;
while(1)
{
keypr();
}
}
(6)单片机独立按键
最新推荐文章于 2024-07-21 13:28:48 发布