Hi everyone,
I have been working on nextion screen with Arduino to control a machine. I am using the debug screen to check the codes, Arduino mega seems to get data, but the led does not turn on.
#include "Nextion.h"
NexButton b0 = NexButton(0, 2, "b0");
NexButton b1 = NexButton(0, 3, "b1");
bool led = false;
NexTouch *nex_listen_list[] =
{
&b0,
&b1,
NULL
};
void b0PopCallback(void *ptr)
{
led = true;
}
void b1PopCallback(void *ptr)
{
led = false;
}
void setup(void)
{
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
nexInit();
b0.attachPop(b0PopCallback, &b0);
b1.attachPop(b1PopCallback, &b1);
}
void loop(void)
{
if (led){
digitalWrite(13,HIGH);
}
else {digitalWrite(13,LOW);}
nexLoop(nex_listen_list);
}