#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar dat1,dat2;
sbit FHDATA=P3^0;
sbit FSDATA=P3^1;
sbit SELECT1=P3^2;
sbit SELECT2=P3^3;
unsigned char code tab[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char code tab_w[]={
0x7F,0xBF,0xDF,0xEF,0xF7,0xfb,0xfd,0xfe};
void delay(uint z) //延时1ms
{
uint i,j;
for(i=z;i>0;i--)
for(j=123;j>0;j--);
}
void init()
{
FHDATA=0;
FSDATA=0;
SELECT1=0;
SELECT2=0;
}
void senddula(unsigned char dat1)
{
SBUF=dat1;
while(TI==0);
TI=0;
SELECT1=0;
delay(2);
SELECT1=1;
}
void sendwela(unsigned char dat2)
{
SBUF=dat2;
while(TI==0);
TI=0;
SELECT2=0;
delay(2);
SELECT2=1;
}
void main()
{
void init();
uchar i=0,j=0;
while(1){
if(i==16)
i=0;
dat1=tab[i];
senddula(dat1);
i++;
if(j==8)
j=0;
dat2=tab_w[j];
sendwela(dat2);
delay(998);
j++;
}
}