三。软件编程
因学的是C51(不懂汇编)这里只提供C语言源程序。 #include
unsigned char BUFFER[]={0,0,0,0,1,1,7};
unsigned char M[]={31,28,31,30,31,30,31,31,30,31,30,31}; unsigned char maxnum[]={59,23,31,12,99}; unsigned char minnum[]={0,0,1,1,0}; unsigned char yy[34];
unsigned char code NUM1[] =
{
0x80,0x7F,0xC0,0xFF,0x40,0x90,0x40,0x8C, // -0- 0x40,0x82,0xC0,0xFF,0x80,0x7F,0x00,0x00, 0x00,0x00,0x00,0x81,0x80,0x81,0xC0,0xFF, // -1- 0xC0,0xFF,0x00,0x80,0x00,0x80,0x00,0x00, 0x80,0xE0,0xC0,0xF0,0x40,0x98,0x40,0x8C, // -2- 0x40,0x86,0xC0,0xC3,0x80,0xC1,0x00,0x00, 0x80,0x40,0xC0,0xC0,0x40,0x84,0x40,0x84, // -3- 0x40,0x84,0xC0,0xFF,0x80,0x7B,0x00,0x00, 0x00,0x0C,0x00,0x0E,0x00,0x0B,0x80,0x89, // -4- 0xC0,0xFF,0xC0,0xFF,0x00,0x88,0x00,0x00, 0xC0,0x47,0xC0,0xC7,0x40,0x84,0x40,0x84, // -5- 0x40,0x8C,0x40,0xFC,0x40,0x78,0x00,0x00, 0x00,0x7F,0x80,0xFF,0xC0,0x84,0x40,0x84, // -6- 0x40,0x84,0x00,0xFC,0x00,0x78,0x00,0x00, 0xC0,0x00,0xC0,0x00,0x40,0xF0,0x40,0xF8, // -7- 0x40,0x0C,0xC0,0x07,0xC0,0x03,0x00,0x00, 0x80,0x7B,0xC0,0xFF,0x40,0x84,0x40,0x84, // -8- 0x40,0x84,0xC0,0xFF,0x80,0x7B,0x00,0x00, 0x80,0x03,0xC0,0x87,0x40,0x84,0x40,0x84, // -9- 0x40,0xC4,0xC0,0x7F,0x80,0x3F,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63, // -:- 0x00,0x63,0x00,0x00,0x00,0x00,0x00,0x00, };
unsigned char code NUM2[]= {
0x00,0x00,0x7f,0x80,0xff,0xc0,0x82,0x40, // -0- 0x8c,0x40,0x90,0x40,0xff,0xc0,0x7f,0x80, 0x00,0x00,0x00,0x00,0x20,0x40,0x60,0x40, // -1- 0xff,0xc0,0xff,0xc0,0x00,0x40,0x00,0x40, 0x00,0x00,0x41,0xc0,0xc3,0xc0,0x86,0x40, // -2-
0x8c,0x40,0x98,0x40,0xf0,0xc0,0x60,0xc0, 0x00,0x00,0x40,0x80,0xc0,0xc0,0x88,0x40, // -3- 0x88,0x40,0x88,0x40,0xff,0xc0,0x77,0x80, 0x00,0x00,0x0c,0x00,0x1c,0x00,0x34,0x00, // -4- 0x64,0x40,0xff,0xc0,0xff,0xc0,0x04,0x40, 0x00,0x00,0xf8,0x80,0xf8,0xc0,0x88,0x40, // -5- 0x88,0x40,0x8c,0x40,0x8f,0xc0,0x87,0x80, 0x00,0x00,0x3f,0x80,0x7f,0xc0,0xc8,0x40, // -6- 0x88,0x40,0x88,0x40,0x0f,0xc0,0x07,0x80, 0x00,0x00,0xc0,0x00,0xc0,0x00,0x83,0xc0, // -7- 0x87,0xc0,0x8c,0x00,0xf8,0x00,0xf0,0x00, 0x00,0x00,0x77,0x80,0xff,0xc0,0x88,0x40, // -8- 0x88,0x40,0x88,0x40,0xff,0xc0,0x77,0x80, 0x00,0x00,0x70,0x00,0xf8,0x40,0x88,0x40, // -9- 0x88,0x40,0x88,0xc0,0xff,0x80,0x7f,0x00, 0x00,0x00,0x00,0xc0,0x01,0x80,0x03,0x00, // -/- 0x06,0x00,0x0c,0x00,0x18,0x00,0x30,0x00, };
unsigned char code HZ_12[] = {
0x80,0x00,0x88,0x1F,0x30,0x48,0x00,0x24, //\调\ 0xF0,0x1F,0x10,0x01,0x50,0x1D,0xF0,0x15, 0x50,0x1D,0x10,0x41,0xF8,0x7F,0x10,0x00, 0x00,0x02,0x00,0x41,0x80,0x41,0x60,0x31, //\分\ 0x18,0x0F,0x00,0x01,0x00,0x21,0x38,0x41, 0x40,0x3F,0x80,0x00,0x00,0x01,0x00,0x01, 0xE0,0x1F,0x20,0x09,0x20,0x09,0x20,0x09, //\时\ 0xE0,0x1F,0x40,0x00,0x40,0x01,0x40,0x26, 0x40,0x40,0xF8,0x7F,0x40,0x00,0x40,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x3F, //\日\ 0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,
0x10,0x11,0xF8,0x3F,0x10,0x00,0x00,0x00, 0x00,0x40,0x00,0x20,0x00,0x10,0xF8,0x0F, //\月\ 0x48,0x02,0x48,0x02,0x48,0x22,0x48,0x42, 0x48,0x42,0xF8,0x3F,0x00,0x00,0x00,0x00, 0x80,0x04,0x40,0x04,0x20,0x04,0x98,0x07, //\年\ 0x90,0x04,0x90,0x04,0xF0,0x7F,0x90,0x04, 0x90,0x04,0x98,0x04,0x90,0x04,0x10,0x04 };
unsigned int disp1,disp2,key1,key2,key; unsigned int ii,jj;
unsigned int i,w,n,xz,CM,TZ,BZ; void Delay(unsigned int ms){ ms=ms*3; while(--ms); }
void num_led(int aa, int bb) { int kk;
for(kk=0;kk<8;kk++){ gate11=key1; gate12=key2;
P2=~NUM1[aa+kk*2];P1=~NUM1[aa+1+kk*2]; Delay(20); P1=0xff;P2=0xff;
gate11=key2; gate12=key1;
P2=~NUM2[bb+15-kk*2];P1=~NUM2[bb+14-kk*2]; Delay(20); P1=0xff;P2=0xff; } }
void display_clock(void) {
key1=key;key2=!key;
disp1=BUFFER[3]/10;disp2=BUFFER[4]-(BUFFER[4]/10)*10; ii=disp1*16;jj=disp2*16; num_led(ii,jj);
P2=0xff;P1=0xff;Delay(60);
相关推荐: