我想用M8和蓝色的LCD做一个5V的电压表,因为蓝色的好漂亮!
可是仿真出来的显示是 0.0
5.0
X.XXXXXXXXXXXXXXXXX
我想让它显示0.00
5.00
x.xx
应该怎么做?用STR命令之后AD来的数值就变了,所以FORMAT也就用不了了。
上截图
下面是代码:
$regfile = "m8def.dat"
$crystal = 1000000
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Cursor Off Noblink
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Dim V As Word
Dim V1 As Single
Dim _change As Byte : _change = 0
V = Getadc(0)
V = V * 5
V1 = V / 1023
Cls
Locate 1 , 1
Lcd V1
|