0

I'm porting some code from Arduino Uno over to a Mega and I want to replace a SoftwareSerial defined in the previous code with one of the built-in UARTs.

Rather than go through and replace all references to the serial port, I'd prefer to create an alias for Serial1. The alias can be a constant.

In my old code, I setup the Software Serial as follows:

//SoftwareSerial HMI(HMIRX, HMITX); // Define software serial for the HMI adapter (RX, TX)

I"m not even sure where to start.

asked Oct 22, 2017 at 3:07

1 Answer 1

2

it is simple #define HMI Serial1

answered Oct 22, 2017 at 7:37
1
  • Alternatively: HardwareSerial &HMI = Serial1; Commented Oct 22, 2017 at 11:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.