Hi I am relatively new to using C++,
I have a little bit of experience using the Arduino IDE but I am a bit stumped when trying to connect a Nextion 3.2 LCD screen
I have looked at a fair few tutorials but whenever I try to upload the code it doesn't do anything
Any help would be most appreciated
Nextion Editor:
Wiring:
- LCD 5v to 5v in
- Arduino VIN to 5v in
- LCD GND & Arduino GND to Ground
- LCD TX to Arduino RX (Pin 2)
- LCD RX to Arduino TX (Pin 1)
Code:
#include <Nextion.h>
int variable1 = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
variable1++; //increase value of variable
if (variable1 == 201) { variable1 =0; } //Reset when reach 201
// Update Number
Serial.print("n0.val=");
Serial.print(variable1);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
//Update Progress bar
Serial.print("j0.val=");
Serial.print(variable1);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
//update gauge
Serial.print("va0.val=");
Serial.print(variable1);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
//update text to Hot! once reach certain value
if (variable1 > 99) {
Serial.print("t0.txt=");
Serial.print(""");
Serial.print("Hot!");
Serial.print(""");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
} else {
Serial.print("t0.txt=");
Serial.print(""");
Serial.print("Normal");
Serial.print(""");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
//Hide Progress bar once reach certain value
if (variable1 > 119) {
Serial.print("vis j0,0");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
} else {
Serial.print("vis j0,1");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
// Change Progress bar colour once reach certain value
if (variable1 > 49) {
Serial.print("j0.pco=63488");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
} else {
Serial.print("j0.pco=1024");
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
}