欢迎来到天天文库
浏览记录
ID:58640926
大小:34.50 KB
页数:7页
时间:2020-10-17
《设计数字报警电压表(按键调节报警电压值).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、.......#include#include#defineucharunsignedchar#defineuintunsignedintucharH,M,L;ucharo;sbitKEY3=P3^5;sbitLED=P2^0;sbitLCD_RS=P2^6;sbitLCD_RW=P2^5;sbitLCD_EP=P2^7;ucharcodedis1[]={"0123456789CV:.V"};ucharcodedis2[]={"0123456789WV:.V"};//0809sbi
2、tSTART=P2^4;sbitEOC=P2^3;sbitOE=P2^2;sbitCLK=P2^1;uchargetdata=0,volt;ucharqian,bai,shi,ge;voidadc0809(){START=0;START=1;START=0;while(EOC==0);OE=1;getdata=P1;OE=0;}voidvolt_result(){volt=getdata*500/255;}voiddingshi()interrupt3{CLK=~CLK;}voiddschushihua(){TMOD=0
3、x20;TH1=0xfb;TL1=0xfb;TR1=1;c.............ET1=1;EA=1;}//延时函数voiddelay(intms){uinti,TempCyc;for(i=0;i4、result;}//写指令voidlcd_wcmd(intcmd){while(lcd_bz());LCD_RS=0;LCD_RW=0;LCD_EP=0;_nop_();_nop_();P0=cmd;_nop_();_nop_();_nop_();c............._nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;P0=(cmd&0x0f)<<4;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_5、nop_();_nop_();_nop_();LCD_EP=0;}voidlcd_pos(ucharpos){lcd_wcmd(pos6、0x80);}/****************写数据函数************************/voidlcd_wdat(uchardat){while(lcd_bz());LCD_RS=1;LCD_RW=0;LCD_EP=0;P0=dat;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_no7、p_();LCD_EP=0;c.............LCD_RS=1;LCD_RW=0;LCD_EP=0;_nop_();_nop_();_nop_();_nop_();P0=(dat&0x0f)<<4;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;}voidlcd_init(){lcd_wcmd(0x38);delay(5);lcd_wcmd(0x0c);delay(5);lcd_wcmd(0x028、);delay(5);lcd_wcmd(0x01);delay(100);}voidxianshi1(){lcd_pos(4);bai=(volt*2)/100;shi=(volt*2)%100/10;ge=(volt*2)%10;lcd_wdat(dis1[10]);lcd_wdat(dis1[11]);lcd_wdat(dis1[12]);lcd_wdat(dis1[bai]);lcd_wdat(dis1[13]);lcd_wdat(dis1[shi]);lcd_wdat(dis1[ge]);c...........9、..lcd_wdat(dis1[14]);}//按键中断voiddelay3(uintk){uintp,q;for(p=k;p>0;p--){for(q=110;q>0;q--);}}voidINT_init(){EX0=1;IT0=1;EX1=1;IT1=1;EA=1;}voiddata_in(void){H=o/
4、result;}//写指令voidlcd_wcmd(intcmd){while(lcd_bz());LCD_RS=0;LCD_RW=0;LCD_EP=0;_nop_();_nop_();P0=cmd;_nop_();_nop_();_nop_();c............._nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;P0=(cmd&0x0f)<<4;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_
5、nop_();_nop_();_nop_();LCD_EP=0;}voidlcd_pos(ucharpos){lcd_wcmd(pos
6、0x80);}/****************写数据函数************************/voidlcd_wdat(uchardat){while(lcd_bz());LCD_RS=1;LCD_RW=0;LCD_EP=0;P0=dat;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_no
7、p_();LCD_EP=0;c.............LCD_RS=1;LCD_RW=0;LCD_EP=0;_nop_();_nop_();_nop_();_nop_();P0=(dat&0x0f)<<4;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;}voidlcd_init(){lcd_wcmd(0x38);delay(5);lcd_wcmd(0x0c);delay(5);lcd_wcmd(0x02
8、);delay(5);lcd_wcmd(0x01);delay(100);}voidxianshi1(){lcd_pos(4);bai=(volt*2)/100;shi=(volt*2)%100/10;ge=(volt*2)%10;lcd_wdat(dis1[10]);lcd_wdat(dis1[11]);lcd_wdat(dis1[12]);lcd_wdat(dis1[bai]);lcd_wdat(dis1[13]);lcd_wdat(dis1[shi]);lcd_wdat(dis1[ge]);c...........
9、..lcd_wdat(dis1[14]);}//按键中断voiddelay3(uintk){uintp,q;for(p=k;p>0;p--){for(q=110;q>0;q--);}}voidINT_init(){EX0=1;IT0=1;EX1=1;IT1=1;EA=1;}voiddata_in(void){H=o/
此文档下载收益归作者所有