我正在开发将在 LCD 上显示输出的系统。
我将变量数据类型声明为浮点数,但 LCD 显示器显示0.00我没有初始化,因为我用0.0
声明它
我希望 LCD 显示器显示0.000,但无论我尝试更改初始化值 LCD 显示器总是显示0.00
.所以,我怎样才能让液晶显示器显示0.000
这是图片的链接
下面是我的代码:
#include <LiquidCrystal.h>
volatile int NbTopsFan;
float flowrate = 0.0;
float volume = 0.0;
int hallSensor = 2;
LiquidCrystal lcd (12, 11, 9, 8, 7, 6);
void rpm() {
NbTopsFan++;
}
void setup(){
pinMode(3, OUTPUT);
pinMode (hallSensor, INPUT);
Serial.begin (9600);
attachInterrupt (0, rpm, RISING);
lcd.begin (16, 2);
lcd.clear ();
}
void loop (){
digitalWrite(3, HIGH);
NbTopsFan=0;
sei();
delay(1000);
cli();
flowrate = NbTopsFan / 7.5;
volume += (flowrate / 60);
lcd.clear ();
lcd.setCursor(0, 0);
lcd.print("flow :");
lcd.print(flowrate);
lcd.print("L/m");
lcd.setCursor(0, 1);
lcd.print("VOl :");
lcd.print(volume);
lcd.print("L");
Serial.print("Pulse");
Serial.print(NbTopsFan);
Serial.print(flowrate);
Serial.print("L/m");
Serial.print(volume,4);
Serial.print("liter");
}