请大佬帮看看,这个数字时钟的电路和代码有没有问题
#include<reg51.h>#define uchar unsigned char#define uint unsigned intsbit rs=P3^3;sbit rw=P3^4;sbit lcden=P3^5;unsigned int a,b,c;uchar count,k;uchar shi,fen,miao;uchar code table[]="12:00:00";void delay(uint z){uint x,y;for(x=0;x<z;x++)for(y=0;y<110;y++);}void w_com(uchar com){rs=0;lcden=0;P1=com;delay(5);lcden=1;delay(5);lcden=0;}void w_data(uchar date){rs=1;lcden=0;P1=date;delay(5);lcden=1;delay(5);lcden=0;}void w_sfm(uchar add,uchar date){uchar shi,ge;shi=date/10;ge=date%10;w_com(0x80+add);w_data(0x30+shi);w_data(0x30+ge);}void init(){uchar num;lcden=0;fen=00;miao=00;shi=00;w_com(0x30);w_com(0x0c);w_com(0x06);w_com(0x00);for(num=0;num<8;num++){w_data(table[num]);delay(5);}w_sfm(0,shi);w_sfm(3,fen);w_sfm(6,miao);TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=1;}void key(){P2=0x0f;//,a=P2; if(P2!=0x0f) {delay(100); if(P2!=0x0f) {a=P2;P2=0x0f0;if(P2!=0x0f0){b=P2;c=a&b;}}}elsec=P2;}void keyscan(){key();if(c==0x88){k++;if(k==1){TR0=0;delay(100);w_com(0x80+0x07);w_com(0x0f);}if(k==2){delay(100);w_com(0x80+0x04);w_com(0x0f);}if(k==3){delay(100);w_com(0x80+0x01);w_com(0x0f);}if(k==4){k=0;delay(100);w_com(0x0c);TR0=1;}}if(c==0x84){if(k==1){miao++;if(miao==60)miao=0;w_sfm(6,miao);w_com(0x80+0x07);}if(k==2){fen++;if(fen==60)fen=0;w_sfm(3,fen);w_com(0x80+0x04);}if(k==3){shi++;if(shi==24)shi=0;w_sfm(0,shi);w_com(0x80+0x01);}}if(c==0x82){if(k==1){miao--;if(miao==-1)miao=59;w_sfm(6,miao);w_com(0x80+0x07);}if(k==2){fen--;if(fen==-1)fen=59;w_sfm(3,fen);w_com(0x80+0x04);}if(k==3){shi--;if(shi==-1)shi=23;w_sfm(0,shi);w_com(0x80+0x01);}}}void main(){rw=0;init();while(1){keyscan();if(count==20){count=0;miao++;if(miao==60){miao=0;fen++;if(fen==60){fen=0;shi++;if(shi==24){shi=0;}w_sfm(0,shi);}w_sfm(3,fen);}w_sfm(6,miao);}}}void timer0() interrupt 1{TH0=(65536-50000)/256; TL0=(65536-50000)%256;count++;}
#include<reg51.h>#define uchar unsigned char#define uint unsigned intsbit rs=P3^3;sbit rw=P3^4;sbit lcden=P3^5;unsigned int a,b,c;uchar count,k;uchar shi,fen,miao;uchar code table[]="12:00:00";void delay(uint z){uint x,y;for(x=0;x<z;x++)for(y=0;y<110;y++);}void w_com(uchar com){rs=0;lcden=0;P1=com;delay(5);lcden=1;delay(5);lcden=0;}void w_data(uchar date){rs=1;lcden=0;P1=date;delay(5);lcden=1;delay(5);lcden=0;}void w_sfm(uchar add,uchar date){uchar shi,ge;shi=date/10;ge=date%10;w_com(0x80+add);w_data(0x30+shi);w_data(0x30+ge);}void init(){uchar num;lcden=0;fen=00;miao=00;shi=00;w_com(0x30);w_com(0x0c);w_com(0x06);w_com(0x00);for(num=0;num<8;num++){w_data(table[num]);delay(5);}w_sfm(0,shi);w_sfm(3,fen);w_sfm(6,miao);TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=1;}void key(){P2=0x0f;//,a=P2; if(P2!=0x0f) {delay(100); if(P2!=0x0f) {a=P2;P2=0x0f0;if(P2!=0x0f0){b=P2;c=a&b;}}}elsec=P2;}void keyscan(){key();if(c==0x88){k++;if(k==1){TR0=0;delay(100);w_com(0x80+0x07);w_com(0x0f);}if(k==2){delay(100);w_com(0x80+0x04);w_com(0x0f);}if(k==3){delay(100);w_com(0x80+0x01);w_com(0x0f);}if(k==4){k=0;delay(100);w_com(0x0c);TR0=1;}}if(c==0x84){if(k==1){miao++;if(miao==60)miao=0;w_sfm(6,miao);w_com(0x80+0x07);}if(k==2){fen++;if(fen==60)fen=0;w_sfm(3,fen);w_com(0x80+0x04);}if(k==3){shi++;if(shi==24)shi=0;w_sfm(0,shi);w_com(0x80+0x01);}}if(c==0x82){if(k==1){miao--;if(miao==-1)miao=59;w_sfm(6,miao);w_com(0x80+0x07);}if(k==2){fen--;if(fen==-1)fen=59;w_sfm(3,fen);w_com(0x80+0x04);}if(k==3){shi--;if(shi==-1)shi=23;w_sfm(0,shi);w_com(0x80+0x01);}}}void main(){rw=0;init();while(1){keyscan();if(count==20){count=0;miao++;if(miao==60){miao=0;fen++;if(fen==60){fen=0;shi++;if(shi==24){shi=0;}w_sfm(0,shi);}w_sfm(3,fen);}w_sfm(6,miao);}}}void timer0() interrupt 1{TH0=(65536-50000)/256; TL0=(65536-50000)%256;count++;}