时间:2024.8.28
作者:Whappy
目的:学习51单片机
代码:
#include <REGX52.H>
#include "intrins.h"
void Delay1ms(unsigned int xms) //@11.0592MHz
{
unsigned char i, j;
while(xms--)
{
_nop_();
i = 2;
j = 199;
do
{
while (--j);
} while (--i);
}
}
void main(void)
{
//P2_0 = 0;
while(1)
{
if(P3_1 == 1)
{
Delay1ms(20); //软件消抖
while(P3_1 == 1)
{
}
Delay1ms(20);
P2_0 = ~ P2_0;
}
}
}