Start a new topic

setText command issue

HI all

I have a code that uses setText (RED) to send back from the Arduino Mega to the Nextion EN 7" to report back the state of a digital pin, code below located inside the void loop, however it is causing the loop or entire program to not run correctly,

when the code is in the loop the Nextion sends the button commands but the Arduino does not respond every time, ie 1 in 6 button presses it may change state of the output, when the code is commented out (via //) or a replacement code, ie set a different pin to HIGH or LOW the code works fine and the output responds every time the button is pressed. any idea why this is, any alternative, like changing a picture box from Green to RED instead of ON or OFF in a text box.

the reason is the button is not directly linked to the output, ie Pump1 as below, needs conditions (further up in the code) to be met for it to turn on, so the fact the button is on may not mean the pump is actually running when the button is pressed, so I want to see from the screen if the pump is on or off regardless if the button is on


//PUMP1 OUTPUT ********************************************************
  if (pump1==HIGH) {
  digitalWrite(relay1Pin, HIGH);
  } else{
  digitalWrite(relay1Pin, LOW);

//PUMP 1 TEXT***********************************************************
  if (pump1txt == HIGH){ 
  t0.setText("ON");  // this is causing the issue
   } // if I replace it with digitalWrite(relay10Pin, HIGH); I have no issues
if (pump1txt == LOW){
  t0.setText("OFF");  // this is causing the issue
  } // if I replace it with digitalWrite(relay10Pin, LOW); I have no issues

Login or Signup to post a comment