How to send text/integers over serial lines on Mega2560?

I bought an Arduino Mega and would like to try sending data to an Uno via RX1/TX1 Pins on the Mega. Is there an example I can use to do this?

Your post was MOVED to its current location as it is more suitable.

Where are you stuck ?

Is it in sending the data or receiving it ?

Personally I would not use pins 0 and 1 on the Mega, but use one of its other 3 hardware serial interfaces which leaves Serial on pins 0 and 1 for debugging

I’d like to know how to connect these pins and if there’s any libraries to make the process of sending/receiving data easier.

Basically you connect the Tx pin from one end to the Rx pin of the other end and vice versa, then Serial.print() from one end and Serial.read() on the other when Serial.available() indicates that something has been received

If you are going to use a Uno as the receiver then you would be wise not to use its 0 and 1 pins because they are used by its hardware Serial interface. Instead consider using SoftwareSerial on the Uno on 2 other pins of your choosing

and make sure both devices share the same GND (connect the GND as well as Rx and Tx)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.