Good day!
I am working on a project where the arduino is connected to a nextion display. The program for the nextion is already fine and so are the connections but the arduino program uploaded successfully but doesn't work.
I tried a simple sketch from the arduino examples and it worked fine using the same board. I am using robotdyn mega 2560 which has the same features of arduino mega.
Last time, the program worked well. But then I put some minor changes in the arduino sketch such as digital inputs and digital writes and the program doesn't work now
Here is my program and I already checked it multiple times and so are the id numbers and such in the nextion display program but I don't see any problems in it.
Arduino_program.ino (7.43 KB)
then I put some minor changes in the arduino sketch such as digital inputs and digital writes and the program doesn't work now
Can you please point out the changes that you made ?
These are the changes i added:
For the declaration of nextion variables:
NexButton on2 = NexButton(8, 11, "b2"); //Nextion HMI page 8 buttons (main page for level 1 password)
NexButton enable2 = NexButton(8, 10, "b3");
NexButton trigger2 = NexButton(8, 12, "b0");
For the press event of the buttons:
void on2PushCallback(void *ptr) //run and stop
{
digitalWrite(D1, LOW);}
void on2PopCallback(void *ptr)
{
digitalWrite(D1, HIGH);}
void enable2PushCallback(void *ptr) //servo enable
{
digitalWrite(D2, LOW);}
void trigger2PushCallback(void *ptr) //press event for trigger
{
digitalWrite(D4, LOW);}
void trigger2PopCallback(void *ptr) //release event for trigger
{
digitalWrite(D4, HIGH);}
For the setup of press events,
on2.attachPush(on2PushCallback);
on2.attachPop(on2PopCallback);
enable2.attachPush(enable2PushCallback);
trigger2.attachPush(trigger2PushCallback);
trigger2.attachPop(trigger2PopCallback);
One thing to check is pin conflicts. D1 is used by the serial port for example. What pins does your display use?
The display only uses the built in rx and tx pins of the robotdyn mega
I already solved the problem. I just put the nextion library folder to the documents/arduino/library folder