|
代码
#include <reg51.h>
void time(unsigned int ucMs);//函数声明
void main(void)
{
unsigned char ucTimes;
#define DELAY_TIME 450
while(1)
{
P1=0xff;
P0=0xff;
for(ucTimes=0;ucTimes<8;ucTimes++){
P0 = P0 - (0x01<<ucTimes);time(DELAY_TIME);}
for(ucTimes=0;ucTimes<8;ucTimes++){
P1 = P1 - (0x01<<ucTimes);time(DELAY_TIME);}
P1=0xff;
P0=0xff;
for(ucTimes=0;ucTimes<8;ucTimes++){
P1 = P1 - (0x80>>ucTimes);time(DELAY_TIME);}
for(ucTimes=0;ucTimes<8;ucTimes++){
P0 = P0 - (0x80>>ucTimes);time(DELAY_TIME);}
}}
void time(unsigned int ucMs)
{
#define DELAYTIMES 239
unsigned char ucCounter;
while(ucMs!=0) {
for(ucCounter=0; ucCounter<DELAYTIMES; ucCounter++) { }
ucMs--;
}
}
|
-
-
跑马灯.zip
36.3 KB, 下载次数: 13, 下载积分: 黑币 -5
|