时间:2024.8.29
作者: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;
unsigned char LEDNum = 0;
while(1)
{
if(P3_1 == 0)
{
Delay1ms(20);
while(P3_1 == 0);
Delay1ms(20);
LEDNum++;
P2 = ~LEDNum++;
}
}
}