总程序:
#include<reg52.h>
#include<intrins.h>
char lie[8]={0x18,0x1c,0x18,0x18,0x18,0x18,0x18,0x7e};
/* {0x1C,0x22,0x22,0x22,0x22,0x22,0x22,0x1C}; //0
{0x18,0x1c,0x18,0x18,0x18,0x18,0x18,0x7e}; //1
{0x00,0x1e,0x30,0x30,0x1c,0x06,0x06,0x3e}, //2
{0x00,0x1e,0x30,0x30,0x1c,0x30,0x30,0x1e}, //3
{0x00,0x30,0x38,0x34,0x32,0x3e,0x30,0x30}, //4
{0x00,0x1e,0x02,0x1e,0x30,0x30,0x30,0x1e}, //5
{0x00,0x1c,0x06,0x1e,0x36,0x36,0x36,0x1c}, //6
{0x00,0x3f,0x30,0x18,0x18,0x0c,0x0c,0x0c}, //7
{0x00,0x1c,0x36,0x36,0x1c,0x36,0x36,0x1c}, //8
{0x00,0x1c,0x36,0x36,0x36,0x3c,0x30,0x1c}}; //9 */
sbit STCP=P2^6; //显示时钟输入(上升沿)
sbit SHCP=P2^5; //移位时钟输入(上升沿)
sbit DS=P2^7; //数据输入端
void delay();
void delay1s();
void delay1ms()
{ unsigned int j;
for(j=0;j<100;j++);
}
/*void delay1s()
{ unsigned char m;
for(m=0;m<20;m++)
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
while(!TF0);
TF0=0;
}
}*/
void delay()
{
_nop_();
_nop_();
_nop_();
}
void main()
{ unsigned char i,b;
// TMOD=0x01;
for(i=0;i<8;i++)
{
for(b=0;b<8;b++)
{
if(0x80&lie)
DS=1; //DS=0x80&lie[y][a];
else DS=0;
SHCP=0;
delay();
SHCP=1;
lie<<=1;
}
STCP=0;
delay1ms();
STCP=1;
P1=i;
}
}
|