可以参考这个 仿真 实例。
#include
#define uchar unsigned char
uchar code ledtab[]=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
sbit start=P2^3;
sbit stop=P2^2;
sbit pause=P2^1;
sbit rstart=P2^0;
uchar str[]="Love CDUT 1956 2016";
uchar cnt=0;
void delay(uchar a)
{
while(a--)for(i=0;i<120;i++);
}
void t0isr() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
cnt++;
if(cnt>10)
{
cnt=0;
if(str[num]=='\0')num=0;
P0=str[num];
num++;
}
}
main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
ET0=1;
EA=1;
while(1)
{
if(start==0)
{
delay(10);
if(start==0)
{
TR0=1;
num=0;
}
}
if(stop==0)
{
delay(10);
if(stop==0)
{
TR0=0;
P0=0xff;
}
}
if(pause==0)
{
delay(10);
if(pause==0)
{
TR0=0;
}
}
if(rstart==0)
{
delay(10);
if(rstart==0)
{
TR0=1;
}
}
}
}
用数码管怎么显示出 “Love CDUT”