1、每隔一分钟,蜂鸣器响一次,按键按一下,计数器清0。 从新开始、#include#include#define uchar unsigned char#define uint unsigned intsbit RS=P20;sbit RW=P21;sbit EN=P22;uchar code dis2=0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39;uchar code p=-;/code 可以不加,加了之后就是固定了这个数组不能对其进行操作、这个一定要注意。uchar j,k,kk,miao,miao1,fen,fen1,shi,shi1;v
2、oid delay_ms(int x)/延时程序,延时1msuint i;while(x-)for(i=0;i120;i+);uchar busy()/对LCD1602进行判断是否为忙uchar status;RS=0;RW=1;EN=1; delay_ms(1);status=P1;EN=0;return status;void write_cmd(uchar cmd)/写命令程序,首先对其进行判忙while(busy()&0x80)=0x80);/对返回进行判断,如果为忙就进行等待RS=0;RW=0;EN=0;P1=cmd;EN=1;delay_ms(1);EN=0;void write_
3、data(uchar dat) while(busy()&0x80)=0x80);RS=1;RW=0;EN=0;P1=dat;EN=1;delay_ms(1);EN=0;void canshu()write_cmd(0x38);delay_ms(1);write_cmd(0x01);delay_ms(1);write_cmd(0x06);delay_ms(1);write_cmd(0x0c);delay_ms(1);/*void xianshi(uchar x,uchar y,uchar *str)uint i=0;if(y=0)write_cmd(0x80|x);if(y=1)write_c
4、md(0xc0|x);for(i=0;i16;i+)write_data(stri);if(p=0)break; */void aaa() interrupt 1TH0=(65535-50000)/256;TL0=(65535-50000)%256;if(+kk=18)miao+;if(miao=10)if(miao1+=5)if(fen+=10)if(fen1+=5)if(shi+=10) if(shi1+=1)shi1=0;shi=0; shi=0;fen1=0;fen=0; miao1=0;miao=0;kk=0;void main()canshu();/xianshi(0,0,p);/
5、xianshi(0,1,p+16);EA=1;ET0=1;TMOD=0x01;TH0=(65535-50000)/256;/如果不准可对其进行修改,比如4000可能更准确TL0=(65535-50000)%256;TR0=1;while(1) write_cmd(0x80|1);write_data(dis2shi);write_cmd(0x80|2);write_data(dis2shi1);write_cmd(0x80|3); write_data(p0);write_cmd(0x80|4);write_data(dis2fen1);write_cmd(0x80|5);write_data(dis2fen);write_cmd(0x80|6); write_data(p0);write_cmd(0x80|7); write_data(dis2miao); write_cmd(0x80|8); write_data(dis2miao1);