请教1602显示数值的问题

2024-11-27 05:32:25
推荐回答(1个)
回答1:

LCD_dsp_string(0,1,"dis[0].dis[1]dis[2]") 表示在第一行,第0列显示字符串dis[0].dis[1]dis[2]" ,若要显示dis[0].dis[1]dis[2]" 中的数

LCD_write_command(0x80);
LCD_write_data(0x40+dis[0]);
LCD_write_command(0x81);
LCD_write_data(0x31); //地址0X31为点
LCD_write_command(0x82);
LCD_write_data(0x40+dis[1]);
LCD_write_command(0x83);
LCD_write_data(0x40+dis[2]);

注意:0X40为字库 0~10的地址,不同控制IC有不同的IC详见你的LCM规格书

void LCD_write_data(unsigned char d)
{

RS=1;
RW=0;
E=1;
P1=d;
delay(1);
E=0;
delay(1);

}

也可以定义一个TAB unsigned char ss[10]={0,1,2,3,4,5,6,7,8,9,10};
LCD_write_command(0x80);
LCD_write_data(ss[dis[0]);
LCD_write_command(0x81);
LCD_write_data(0x31); //地址0X31为点
LCD_write_command(0x82);
LCD_write_data(ss[dis[1]);
LCD_write_command(0x83);
LCD_write_data(ss[dis[2]);