我有一个带有这些 Nextion 显示器的 Arduino MEGA。我创建了一个不错的显示器,我的目标是显示模拟输入。但是我注意到这个显示器不能显示小数(使用数字“小部件”)。所以我使用“文本”小部件来做到这一点,不幸的是它不起作用,有人知道为什么吗?
#include "Nextion.h"
#define RES 1023
#define AREF 5
int voltage_pin=A0;
int raw_voltage;
double voltage;
String voltage2;
void setup() {
Serial.begin(9600);
}
void loop() {
raw_voltage=analogRead(voltage_pin);
voltage=raw_voltage*AREF/RES;
Serial.print("n3.val=");
Serial.print(raw_voltage);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
String voltage2=String(voltage);
Serial.print("t10.txt=");
Serial.print(voltage2);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
delay(100);
}
提前致谢!:)