蓝桥杯板子:
程序代码:
#include <STC15F2K60S2.H>
#include "intrins.h"
void Delay1ms(int x);
void ledrun()
{
unsigned char i;
for(i=0;i<3;i++)
{
P2 = 0x80;
P0 = 0x0;
Delay1ms(500);
P0 = 0xff;
Delay1ms(500);
}
for(i=1;i<=8;i++)
{
P0 = 0xFF << i;
Delay1ms(500);
}
for(i=1;i<=8;i++)
{
P0 = ~(0xFF << i);
Delay1ms(500);
}
}
void main()
{
while(1)
{
ledrun();
}
}
void Delay1ms(int x) //@11.0592MHz
{
int y;
y = x;
while(x--)
{
unsigned char data i, j;
_nop_();
_nop_();
_nop_();
i = 11;
j = 190;
do
{
while (--j);
} while (--i);
}
x = y;
}
实验结果: