这是C语言程序,可以调试出来
#include
#include
unsigned char segout[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned int code tab[]={
0x02,0x01,0x42,0x01,0x42,0x02,0x42,0x04,0x42,0x08,0x42,0x30,0x42,0xC0,0x7F,0x00,
0x42,0xC0,0x42,0x30,0x42,0x08,0x42,0x04,0xC2,0x02,0x46,0x03,0x02,0x02,0x00,0x00,
0x00,0x04,0x04,0x08,0x04,0x10,0x04,0x20,0x04,0xC0,0x07,0x02,0x00,0x01,0xFF,0xFE,
0x03,0x00,0x02,0x80,0x04,0x40,0x08,0x20,0x18,0x10,0x00,0x18,0x00,0x10,0x00,0x00,
0x00,0x00,0x3F,0xF1,0x00,0x02,0x00,0x0C,0xFF,0xF0,0x00,0x00,0x40,0x00,0x4F,0xFC,
0x48,0x00,0x48,0x00,0x7F,0xFF,0x48,0x08,0x48,0x04,0xDF,0xF8,0x48,0x00,0x00,0x00,
0x20,0x20,0x22,0x20,0x29,0xBF,0x24,0x20,0xF6,0x40,0x20,0x00,0x27,0xFC,0x24,0x02,
0x24,0x02,0x24,0x42,0xF4,0x22,0x2F,0xC2,0x24,0x02,0x60,0x02,0x20,0x0E,0x00,0x00,
0x02,0x20,0x0C,0x20,0x88,0x20,0x69,0x20,0x09,0x20,0x09,0x22,0x89,0x21,0x69,0x7E,
0x09,0x60,0x09,0xA0,0x19,0x20,0x28,0x20,0xC8,0x20,0x0A,0x60,0x0C,0x20,0x00,0x00,
0x00,0x00,0x7F,0xFF,0x44,0x20,0x5A,0x10,0x69,0xE1,0x30,0x81,0x24,0x82,0x24,0x8C,
0xA4,0xF0,0x64,0x80,0x24,0xFC,0x2C,0x82,0x25,0x82,0x28,0x82,0x30,0x0E,0x00,0x00
};
sbit CLK1=P2^0;
sbit DATA1=P2^1;
sbit SC1=P2^2;
sbit CLK=P2^3;
sbit DATA=P2^4;
sbit SC =P2^5;
void delay(unsigned char t)
{
while(t--);
}
void Sendbyte(unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++)
{
CLK=0;
DATA=dat&0x80;
dat<<=1;
CLK=1;
}
}
void Out595(void)
{
SC=0;
_nop_();
SC=1;
}
void Send2byte(unsigned char dat1,unsigned char dat2)
{
Sendbyte(dat1);
Sendbyte(dat2);
Out595();
}
void Sendseg(unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++)
{
CLK1=0;
DATA1=dat&0x01;
dat>>=1;
CLK1=1;
}
}
void Out5951(void)
{
SC1=0;
_nop_();
SC1=1;
}
void Send2seg(unsigned char dat1,unsigned char dat2)
{
Sendseg(dat1);
Sendseg(dat2);
Out5951();
}
void main()
{
unsigned char i,k,l;
while(1)
{
for(k=0;k<81;k++)
for(l=5;l>0;l--)
for(i=0;i<16;i++)
{
if(i<8)
Send2byte(0xff,~segout[i]);
else
Send2byte(~segout[i],0xff);
Send2seg(tab[(i+k)*2+1],tab[(i+k)*2]);
delay(200);
Send2byte(0xff,0xff);
}
}
}