Start a new topic

Arduino Mega: sendme fails

I had to switch from an Arduino UNO to a Mega recently due to memory shortage ;-) I am using the "sendme" command to retrieve the current page ID: SoftwareSerial nextion(2, 3); ... byte getPage() { char buf[6]; char *cp = buf; SendCmd("sendme"); delay(10); while(nextion.available() && (cp-buf)

Sorry, I messed up the code:

...
SoftwareSerial nextion(2, 3);
...

byte getPage()
{
  char buf[6];
  char *cp = buf;

  SendCmd("sendme");
  delay(10);
  while(nextion.available() && (cp-buf)<sizeof(buf))
  {
  *cp++ = nextion.read();
  }
  return buf[1];
}

...and the text as well. Dang.

Problem is, the code to get the current page ID worked on the UNO, but fails on the MEGA. The "nextion.available()" call never returns TRUE at all.

MIchael

 

Oops... Found it. The MEGA does not support interrupts on all digital ports and 2/3 are among those. Had to use 10/11 for SoftwareSerial - now it works again.

Never mind :-)

 

Login or Signup to post a comment