已阅读5页,还剩27页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
初步程序:#include#define uchar unsigned charsbit P3_4=P34;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x86,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz4;int qw,bw,sw,gw,a,b,c;void disp(void)for(c=3;c=0;c-)SBUF=tabszc;while(!TI);TI=0;void scjs(void)interrupt 3TH1=0X3C;TL1=0xB0;a=a+1;if(a=2)a=0;P3_4=!P3_4;if(P3_4=0)b=TH0*256+TL0;/yw=sz0=b/100000;/ww=sz0=b/10000%10;qw=sz0=b/1000%10;bw=sz1=b/100%10;sw=sz2=b/10%10;gw=sz3=b%10;disp();main()TMOD=0x15;IE=0X88;TH1=0X3C;TL1=0XB0;TR0=1;TR1=1;a=0;while(1);2#include#define uchar unsigned charsbit P3_4=P34;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x06,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz6;int yw,ww,qw,bw,sw,gw,a,b,c,d,e,f;void disp(void)for(c=5;c=0;c-)SBUF=tabszc;while(!TI);TI=0;void scjs(void)interrupt 3TH1=0X3C;TL1=0xB0;a=a+1;if(a=2)a=0;P3_4=!P3_4;if(P3_4=0)b=TH0*256+TL0;d=34;e=6;f=7;qw=sz0=b/100000;bw=sz1=b/10000%10;sw=sz2=b/1000%10;gw=sz3=b/100%10;yw=sz4=b/10%10;ww=sz5=b%10;disp();main()TMOD=0x15;IE=0X88;TH1=0X3C;TL1=0XB0;TR0=1;TR1=1;a=0;while(1);3#include#define uchar unsigned charsbit P3_4=P34;sbit jia=P20;sbit jian=P21;sbit gl=P22;sbit hp=P23;unsigned char keycnt=0;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x06,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz6;int yw,ww,qw,bw,sw,gw,a,b,c,d,e,f;d=46; /单价e=00; /公里数f=00;/jiage=d*e; /金额void disp(void)for(c=5;c=0;c-)SBUF=tabszc;while(!TI);TI=0;void KEY() /按键扫描程序unsigned char i,j;if(hp=0)for(i=20;i0;i-) /延时去干扰for(j=248;j0;j-);if(hp=0)keycnt+;switch(keycnt) /按下次数判断case 1: /第一次按下d=40;break;case 2: /第二次按下d=50;break;case 3: /第三次按下d=60;keycnt=0; /重新开始判断键值break;while(hp=0); void scjs(void)interrupt 3TH1=0X3C;TL1=0xB0;a=a+1;if(a=2)a=0;P3_4=!P3_4;if(P3_4=0)/b=TH0*256+TL0;f=e*d/10;qw=sz0=d/10%10;bw=sz1=d%10;sw=sz2=e/10%10;gw=sz3=e%10;yw=sz4=f/10%10;ww=sz5=f%10;if(jia=0)d+;if(jian=0)d-;if(gl=0)e=5;disp();KEY(); main()void KEY();TMOD=0x15;IE=0X88;TH1=0X3C;TL1=0XB0;TR0=1;TR1=1;a=0;while(1);4#include#define uchar unsigned charsbit P3_4=P34;sbit jia=P20;sbit jian=P21;sbit gl=P22;sbit hp=P23;sbit j=P24;unsigned char keycnt=0;unsigned char cnt=0;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x06,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz6;int yw,ww,qw,bw,sw,gw,a,b,c,d,e,f,g;d=46; /单价e=00; /公里数f=00;/jiage=d*e; /金额void jishuqi()if(j=0)cnt+;if(cnt=100)e+;cnt=0;void disp(void)for(c=5;c=0;c-)SBUF=tabszc;while(!TI);TI=0;void KEY() /按键扫描程序unsigned char i,j;if(hp=0)for(i=20;i0;i-) /延时去干扰for(j=248;j0;j-);if(hp=0)keycnt+;switch(keycnt) /按下次数判断case 1: /第一次按下d=46;break;case 2: /第二次按下d=12;break;case 3: /第三次按下d=78;keycnt=0; /重新开始判断键值break;while(hp=0); void scjs(void)interrupt 3TH1=0X3C;TL1=0xB0;a=a+1;if(a=2)a=0;P3_4=!P3_4;if(P3_4=0)/b=TH0*256+TL0;if(e3)f=g;else f=5;/g=e*d/10;/f=e*d/10+5;qw=sz0=d/10%10;bw=sz1=d%10;sw=sz2=e/10%10;gw=sz3=e%10;yw=sz4=f/10%10;ww=sz5=f%10;if(jia=0)d+;if(jian=0)d-;if(gl=0)e=5;disp();KEY();jishuqi(); main()void KEY();TMOD=0x15;IE=0X88;TH1=0X3C;TL1=0XB0;TR0=1;TR1=1;a=0;while(1);5#include#define uchar unsigned charsbit P3_4=P34;sbit jia=P20;/价格加sbit jian=P21;/价格减sbit gl=P22; /公里sbit hp=P23; /换屏sbit j=P24;/记数unsigned char keycnt=0;unsigned char cnt=0;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x06,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz6;int yw,ww,qw,bw,sw,gw,a,b,c,d,e,f,g;d=46; /单价e=03; /公里数f=05;/jiage=d*e; /金额/*void jishuqi()if(j=0)cnt+;if(cnt=100)e+;cnt=0;*/*void disp(void)for(c=5;c=0;c-)SBUF=tabszc;while(!TI);TI=0;void KEY() /按键扫描程序unsigned char i,j;if(hp=0)for(i=20;i0;i-) /延时去干扰for(j=248;j0;j-);if(hp=0)keycnt+;switch(keycnt) /按下次数判断case 1: /第一次按下d=46;break;case 2: /第二次按下d=12;break;case 3: /第三次按下d=78;keycnt=0; /重新开始判断键值break;while(hp=0); void led(void)qw=sz0=d/10%10;bw=sz1=d%10;sw=sz2=e/10%10;gw=sz3=e%10;yw=sz4=f/10%10;ww=sz5=f%10;void scjs(void)interrupt 3TH1=0X3C;TL1=0xB0;a=a+1;if(a=2)a=0;P3_4=!P3_4;if(P3_4=0)/b=TH0*256+TL0;/f=5;if(jia=0)d+;if(jian=0)d-;if(gl=0)e+;if(e3)g=e*d/10;f=g;/f=e*d/10+5;led();disp();KEY();jishuqi(); main()void KEY();TMOD=0x15;IE=0X88;TH1=0X3C;TL1=0XB0;TR0=1;TR1=1;a=0;while(1);6#include#define uchar unsigned charsbit P3_4=P34;sbit jia=P20;/价格加sbit jian=P21;/价格减sbit gl=P22; /公里sbit hp=P23; /换屏sbit j=P24;/记数unsigned char keycnt=0;unsigned char cnt=0;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x06,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz6;int yw,ww,qw,bw,sw,gw,a,b,c,d,e,f,g;d=46; /单价e=03; /公里数f=05;/jiage=d*e; /金额void jishuqi()if(j=0)cnt+;switch(cnt)case 10:e+;cnt=0;break;while(hp=0);void disp(void)for(c=5;c=0;c-)SBUF=tabszc;while(!TI);TI=0;void KEY() /按键扫描程序unsigned char i,j;if(hp=0)for(i=20;i0;i-) /延时去干扰for(j=248;j0;j-);if(hp=0)keycnt+;switch(keycnt) /按下次数判断case 1: /第一次按下d=46;break;case 2: /第二次按下d=12;break;case 3: /第三次按下d=78;keycnt=0; /重新开始判断键值break;while(hp=0); void led(void)qw=sz0=d/10%10;bw=sz1=d%10;sw=sz2=e/10%10;gw=sz3=e%10;yw=sz4=f/10%10;ww=sz5=f%10;void scjs(void)interrupt 3TH1=0X3C;TL1=0xB0;a=a+1;if(a=2)a=0;P3_4=!P3_4;if(P3_4=0)/b=TH0*256+TL0;/f=5;if(jia=0)d+;if(jian=0)d-;if(gl=0)e+;if(e3)g=e*d/10;f=g;led();disp();KEY();jishuqi(); main()void KEY();TMOD=0x15;IE=0X88;TH1=0X3C;TL1=0XB0;TR0=1;TR1=1;a=0;while(1);7#include#define uchar unsigned charsbit P3_4=P34;sbit jia=P20;/价格加sbit jian=P21;/价格减sbit gl=P22; /公里sbit hp=P23; /换屏sbit j=P24;/记数unsigned char keycnt=0;unsigned char cnt=0;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x06,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz6;int yw,ww,qw,bw,sw,gw,a,b,c,d,e,f,g,u,v,w,z;d=46; /单价e=03; /公里数f=05;u=12;/时v=00;/分w=00;/秒/jiage=d*e; /金额void jishuqi()if(j=0)cnt+;switch(cnt)case 10:e+;cnt=0;break;while(hp=0);void disp(void)for(c=5;c=0;c-)SBUF=tabszc;while(!TI);TI=0;void KEY() /按键扫描程序unsigned char i,j;if(hp=0)for(i=20;i0;i-) /延时去干扰for(j=248;j0;j-);if(hp=0)keycnt+;switch(keycnt) /按下次数判断case 1: /第一次按下d=46;break;case 2: /第二次按下d=12;break;case 3: /第三次按下d=78;keycnt=0; /重新开始判断键值break;while(hp=0); void led(void) /显示时间z=TH0*256+TL0;if(z3)w+;z=0;if(w59)v+;w=0;if(v59)u+;v=0;if(u23)u=0; qw=sz0=u/10%10;bw=sz1=u%10;sw=sz2=v/10%10;gw=sz3=v%10;yw=sz4=w/10%10;ww=sz5=w%10;void led1(void) /显示 价格 里程 金额qw=sz0=d/10%10;bw=sz1=d%10;sw=sz2=e/10%10;gw=sz3=e%10;yw=sz4=f/10%10;ww=sz5=f%10;void scjs(void)interrupt 3TH1=0X3C;TL1=0xB0;a=a+1;if(a=3)a=0;P3_4=!P3_4;if(P3_4=0)/b=TH0*256+TL0;/f=5;if(jia=0)d+;if(jian=0)d-;if(gl=0)e+;if(e3)g=e*d/10;f=g;led();disp();KEY();jishuqi(); main()void KEY();TMOD=0x15;IE=0X88;TH1=0X3C;TL1=0XB0;TR0=1;TR1=1;a=0;while(1);8#include#define uchar unsigned charsbit P3_4=P34;sbit jia=P20;/价格加sbit jian=P21;/价格减sbit gl=P22; /公里sbit hp=P23; /换屏sbit j=P24;/记数unsigned char keycnt=0;unsigned char cnt=0;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x06,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz6;int yw,ww,qw,bw,sw,gw,a,b,c,d,e,f,g,u,v,w,z;d=46; /单价e=03; /公里数f=05;u=12;/时v=00;/分w=00;/秒/jiage=d*e; /金额void jishuqi()if(j=0)cnt+;switch(cnt)case 10:e+;cnt=0;break;while(hp=0);void disp(void)for(c=5;c=0;c-)SBUF=tabszc;while(!TI);TI=0;void KEY() /按键扫描程序unsigned char i,j;if(jian=0)for(i=20;i0;i-) /延时去干扰for(j=248;j0;j-);if(hp=0)keycnt+;switch(keycnt) /按下次数判断case 1: /第一次按下d=46;break;case 2: /第二次按下d=12;break;case 3: /第三次按下d=78;keycnt=0; /重新开始判断键值break;while(hp=0); void shizhong(void)z=TH0*256+TL0;if(z1)w+;z=0;if(w59)v+;w=0;if(v59)u+;v=0;if(u23)u=0; void led(void) /显示时间if(jian=0)u+;if(gl=0)v+;if(hp=0)w+;qw=sz0=u/10%10;bw=sz1=u%10;sw=sz2=v/10%10;gw=sz3=v%10;yw=sz4=w/10%10;ww=sz5=w%10;void led1(void) /显示 价格 里程 金额KEY();qw=sz0=d/10%10;bw=sz1=d%10;sw=sz2=e/10%10;gw=sz3=e%10;yw=sz4=f/10%10;ww=sz5=f%10;void scjs(void)interrupt 3TH1=0X3C;TL1=0xB0;a=a+1;if(a=12)a=0;P3_4=!P3_4;if(P3_4=0)/b=TH0*256+TL0;/f=5;/*if(jia=0)d+;if(jian=0)d-;if(gl=0)e+;*/if(e3)g=e*d/10;f=g;shizhong();if(jia=0)led();else led1();disp();jishuqi(); main()void KEY();TMOD=0x15;IE=0X88;TH1=0X3C;TL1=0XB0;TR0=1;TR1=1;a=0;while(1);9最终程序#include#include #include #define uchar unsigned charsbit P3_4=P34;sbit jia=P20;/价格加sbit jian=P21;/价格减sbit gl=P22; /公里sbit hp=P23; /换屏sbit j=P24;/记数unsigned char keycnt=0;unsigned char cnt=0;bit write=0; /写24C08 的标志;/code uchar tab10=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,;/code uchar tab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,;code uchar tab10=0xbf,0x06,0xdb,0xcf,0x66,0xed,0xfd,0x87,0xff,0xef,;uchar sz6;int yw,ww,qw,bw,sw,gw,a,b,c,d,e,f,g,u,v,w,z;d=46; /单价e=00; /公里数f=05;u=12;/时v=00;/分w=00;/秒/jiage=d*e; /金额/24C08 读写驱动程序/sbit scl=P34; / 24c08 SCLsbit sda=P35; / 24c08 SDAvoid delay1(unsigned char x) unsigned int i;for(i=0;ix;i+);void flash() ; ; void x24c08_init() /24c08 初始化子程序scl=1; flash(); sda=1; flash();void start() /启动(I方C)总线sda=1; flash(); scl=1; flash(); sda=0; flash(); scl=0; flash();void stop() /停止(I方C)总线sda=0; flash(); scl=1; flash(); sda=1; flash();void writex(unsigned char j) /写一个字节 unsigned char i,temp;temp=j;for (i=0;i8;i+)temp=temp1; scl=0; flash(); sda=CY; flash(); scl=1; flash();scl=0; flash(); sda=1; flash();unsigned char readx() /读一个字节unsigned char i,j,k=0;scl=0; flash(); sda=1;for (i=0;i8;i+)flash(); scl=1; flash();if (sda=1) j=1;else j=0;k=(k1)|j;scl=0;flash(); return(k);void clock() /(I方C)线时钟unsigned char i=0;scl=1; flash();while (sda=1)&(i255)i+;scl=0; flash();/从24c02 的地址address 中读取一个字节数据/unsigned char x24c08_read(unsigned char address)unsigned char i;start(); writex(0xa0);clock(); writex(address);clock(); start();writex(0xa1); clock();i=readx(); stop();delay1(10);return(i);/向24c02 的address 地址中写入一字节数据info/void x24c08_write(unsigned char address,unsigned char info)EA=0;start(); writex(0xa0);clock(); writex(address);clock(); writex(info);clo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年反假测试题附答案
- 2025年辐射安全与防护培训考试题及答案
- 健康饮食指南与生活习惯测试答案
- 2025年第三季度基本公共卫生知识培训考试试卷及答案
- 2025高级政工师理论考试题库及答案含各题型
- 环境保护与可持续发展知识测试试题集
- 康复科患者心理评估指南与答案示例
- 甘肃银行从业资格考试模拟试题及答案
- 初级保育员安全防护考试真题及解析
- 幼儿园递接物品礼仪规范
- 电厂保洁服务合同范本
- 2024年甘肃省公务员考试申论真题(含答案)
- 湖北成人学士学位英语真题及答案
- 纳米材料止血技术-洞察及研究
- 互联网农业课件
- 2025年道路运输两类人员安全员考试考核题库及答案
- 统编版(2024)八年级上册历史全册教材问题参考答案
- 冠脉搭桥术的手术方法和并发症
- 沙僧介绍课件图片
- 二年级上册数学应用题100道含完整答案【名师系列】
- 2025年湖北省武汉市黄陂区中考语文三模试题(含答案)
评论
0/150
提交评论