注:本文主要利用keil和proteus软件联合仿真51单片机进行跑马灯实例(软件延时)。
keil 程序
#include <REGX51.H>
void delay(unsigned int time)
{
unsigned char j;
for(;time>0;time--)
for(j=0;j<255;j++);
}
unsigned int i=0;
unsigned code led[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void main()
{
P1=led[0];
while(1)
{
i++;
if(i==8)
i=0;
P1=led[i];
delay(1000);
}
}
proteus仿真