完整程式碼
#include "reg51.h"
#define COLS 16
#define ROWS 2
#define NUMS 4
#define SPACE 2
void delay(unsigned int);
char ScanLine=0;
char i=0;
char j;
char k=COLS+SPACE;
sbit ctrls=0x96;
sbit P1_4=0x94;
sbit P1_5=0x95;
unsigned char *ptr1[COLS];
unsigned char *ptrn[COLS];
unsigned char code pattern[(COLS+SPACE)*NUMS][ROWS]=
{{0x45,0xff},{0x15,0xc0},
{0x55,0xd5},{0x40,0xd5},
{0x7f,0xd5},{0x47,0xd5},
{0x10,0xc0},{0x55,0xd5},
{0x45,0xd5},{0xdf,0xff},
{0xef,0xdf},{0xf0,0xef},
{0x17,0xf0},{0xf7,0xef},
{0x87,0xdf},{0xff,0xff},
{0xff,0xff},{0xff,0xff},
{0x6e,0xdf},{0xad,0xef},
{0x4b,0xf7},{0xef,0xe8},
{0xff,0xdf},{0x03,0xdc},
{0xfb,0xde},{0x7d,0xdf},
{0xbd,0xdf},{0x02,0xd0},
{0xfb,0xdf},{0xfb,0xde},
{0xfb,0xdd},{0x03,0xde},
{0xff,0xdf},{0xff,0xff},
{0xff,0xff},{0xff,0xff},
{0xdf,0xff},{0xdf,0xdf},
{0xdf,0xef},{0xdd,0xf7},
{0xd3,0xf9},{0x1f,0xfe},
{0xdf,0xff},{0xc0,0xff},
{0xdf,0xff},{0x1f,0xe0},
{0xd7,0xdf},{0xdb,0xdf},
{0xdd,0xdf},{0xdd,0xdf},
{0xdf,0xc3},{0xff,0xff},
{0xff,0xff},{0xff,0xff},
{0x00,0xe0},{0xee,0xee},
{0xe0,0xe0},{0xee,0xee},
{0x0e,0xee},{0xff,0xff},
{0xf7,0xe1},{0xf8,0xed},
{0x85,0xed},{0xb5,0xe1},
{0xb5,0xff},{0xb5,0xe1},
{0xb5,0xed},{0x85,0xed},
{0xfd,0xe1},{0xff,0xff},
{0xff,0xff},{0xff,0xff} };
main()
{
void ShiftLeft(void);
char i;
IE=0x82;
TMOD=0x01;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
P1_4=0;
P1_5=0;
TR0=1;
for(i=0;i<COLS;i++)
*(ptr1+i)=*(pattern+i);
while(1)
{
for(i=0;i<COLS;i++)
*(ptrn+i)=*(pattern+i+k);
for(i=0;i<COLS;i++)
{
delay(100000);
ShiftLeft();
}
k=k+COLS+SPACE;
if(k==(COLS+SPACE)*4)
k=0;
}
}
void ShiftLeft(void)
{
char i;
char *temp;
TR0=0;
temp=*ptrn;
for(i=0;i<COLS-1;i++)
{
*(ptr1+i)=*(ptr1+i+1);
*(ptrn+i)=*(ptrn+i+1);
}
*(ptr1+COLS-1)=temp;
TR0=1;
}
void T0_int(void) interrupt 1
{
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
ctrls=1;
j=0;
P2=*(*(ptr1+i)+j);
P1_4=1;
P1_4=0;
j++;
P2=*(*(ptr1+i)+j);
P1_5=1;
P1_5=0;
P1=ScanLine;
ctrls=0;
ScanLine++;
i++;
if(ScanLine==16)
{
ScanLine=0;
i=0;
}
}
void delay(unsigned int count)
{
int i;
for(i=0;i<count;i++)
;
} |