完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
感谢您能抽出时间来看一下愚生的问题。查阅了些资料,依然不知问题所在。可能是在下比较愚笨,无法看清本质,还请各位大侠指点迷津,在下感激不尽!这是一个12864显示的小函数。如有陋处,还请多多包涵,本人小白一枚。 问题如下: 我的想法是,按某个键一下,12864上的显示就会在dis12[][10]这个数组里面一个一个显示。但不知道为什么,只能显示51%,在按的话,就成了50%了,且后面都是50%。就酱。 代码不美,将就的看吧。控制的按键的部分已经红字标出。 该链接附有视频,在愚生的QQ空间相册里,12864的那个,密码12864。 https://user.qzone.qq.com/183137 ... eNPCldR1a6RwLVnUdc_ 步入正题,代码如下: #include #include #include #define uchar unsigned char #define uint unsigned int #define LCD_data P0 ***it col1=P1^7; //列端口定义 ***it col2=P1^6; ***it col3=P2^0; ***it col4=P2^1; ***it LCD_EN=P3^4; ***it LCD_RS=P3^5; ***it LCD_RW=P3^6; ***it LCD_PSB=P3^7; uchar code dis0[]={"****智能控制****"}; uchar code dis1[]={"当前功能显示区"}; uchar code dis2[]={"当前水温:"}; uchar code dis3[]={"当前水位比: 50%"}; uchar code dis4[]={"按S17 开始上水"}; uchar code dis5[]={"目标水位比: 50%"}; uchar code dis6[]={"按 S5 停止上水"}; uchar code dis7[]={"上水中..."}; uchar code dis8[]={"按S18 开始加热"}; uchar code dis9[]={"目标水温:"}; uchar code dis10[]={"按 S6 停止加热"}; uchar code dis11[]={"加热中..."}; uchar code dis12[][10]={"51%","52%","53%","54%","55%","56%","57%","58%","59%","60%", //0-9 "61%","62%","63%","64%","65%","66%","67%","68%","69%","70%", //10-19 "71%","72%","73%","74%","75%","76%","77%","78%","79%","80%", //20-29 "81%","82%","83%","84%","85%","86%","87%","88%","89%","90%", //30-39 "91%","92%","93%","94%","95%","96%","97%","98%","99%","100%"};//40-49 uchar code dis13[][10]={"49%","48%","47%","46%","45%","44%","43%","42%","41%","40%",//0-9 "39%","38%","37%","36%","35%","34%","33%","32%","31%","30%"};//10-19 /*uchar code dis12[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00};//清行*/ void delay1ms(uint); void dekay(uchar); void keyscan(); void write_cmd(uchar cmd); void write_dat(uchar dat); void lcd_pos(uchar X,uchar Y); void lcd_init(); uchar num,i,m,n,temp; uint counter,a,counter1,b; uint add0; void main()//固定界面显示 { //uint add0,add1,minus0,minus1; delay1ms(10); lcd_init(); lcd_pos(0,0);//智能控制 i=0; while(dis0!=' |