按键设置电压显示

上传人:子 文档编号:41838901 上传时间:2018-05-31 格式:DOC 页数:9 大小:30.50KB
返回 下载 相关 举报
按键设置电压显示_第1页
第1页 / 共9页
按键设置电压显示_第2页
第2页 / 共9页
按键设置电压显示_第3页
第3页 / 共9页
按键设置电压显示_第4页
第4页 / 共9页
按键设置电压显示_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《按键设置电压显示》由会员分享,可在线阅读,更多相关《按键设置电压显示(9页珍藏版)》请在金锄头文库上搜索。

1、按键设置电压显示按键设置电压显示#define uchar unsigned char#define uint unsigned int#define BIT(x) (10;x-)for(y=1100;y0;y-);void write_com(uchar com) PORTC/PORTCPORTA=com;PORTC|=BIT(4);delay(5); PORTCdelay(5);void write_dat(uchar dat)PORTC|=BIT(2);/PORTCPORTA=dat;PORTC|=BIT(4);delay(5);PORTCdelay(5); void init_1602

2、()PORTCPORTD=i; /把 i 的值赋给 D 口key=PIND; /读出 D 口的数据j=keywhile(j=0XF0);while(key_press(); /松手检测switch(key)case 0xEE:num+;a=0;break;case 0xDE:num+;a=1;break; case 0xBE: num+;a=2;break;case 0x7E:num+;a=3;break;case 0xED:num+;a=4;break;case 0xDD:num+;a=5;break;case 0xBD:num+;a=6;break;case 0x7D:num+;a=7;b

3、reak;case 0xEB:num+;a=8;break;case 0xDB:num+;a=9;break;case 0xBB:write_com(0x80+0x40+1);write_dat(.);break;case 0x7B:num=0;write_com(0x80+0x40);for(b=0;b5;b+)write_dat(table2b); break;/* case 0xE7:key=0xC;break;case 0xD7:key=0xD;break;case 0xB7:key=0xE;break;case 0x77:key=0xF;break;default:key=16;*/

4、 if(num=1)write_com(0x80+0x40);write_dat(tablea);temp=a*100;if(num=2) write_com(0x80+0x40+2);write_dat(tablea);temp1=a*10;if(num=3)write_com(0x80+0x40+3);write_dat(tablea);temp2=a;temp3=(temp+temp1+temp2)/2+5;n0=temp3/100;n1=temp3%100/10;n2=temp3%10;write_com(0x80+0x40+8);write_dat(tablen0);write_dat(tablen1);write_dat(tablen2); / return key;int main()DDRA=0xff;DDRC=0xff;PORTA=0xff;PORTC|=0x00;init_1602();write_com(0x80);for(b=0;b14;b+)write_dat(table1b);write_com(0x80+0x40);for(b=0;b5;b+)write_dat(table2b); / DDRB=0XFF;/ PORTB=0XFF;while(1)key_scan();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号