In this code we are using the Arduino UNO (Adafruit Metro 328) default Serial UART to communicate with the Mega, The Arduino waits for the Serial UART to receive a message, if the data is a refence what is in the code, in this case is a letter x or a the code will turn ON or OFF the LED on the Arduino UNO (Adafruit Metro 328).Īrduino Mega to Arduino Leonardo …. Read one value from the Serial buffer and store it in the variable com Check if there is anything in the Serial Buffer when you type the letter x or a on the text window on the Serial Console it sends it to the Arduino Mega, then the Arduino Mega sends it to the Arduino UNO(Adafruit Metro 328) through the 2nd UART Serial port with the Serial1.write(Serial.read()) command.
This is going to communicate with the Arduino UNO(Adafruit Metro 328). We are also calling upon the 2nd UART Serial port by calling Serial1.being at a 9600 baud rate. This is going to listen to the Computer for instructions through the USB cable. What we are doing in this code is calling on the Arduino Mega's default UART Serial port by calling Serial.begin at a 9600 baud speed rate. Write what is received to the default serial port Check for received Characters from the computer
The connections will be UART to UART, SoftwareSerial to SoftwareSerial, UART to SoftwareSerial, and ALL 3 connected together!! :)īefore you make the physical wire connections.
If you ever wonder how to use the other Serial ports on the Arduino Mega 2560 R3, but don't know where to start? This short tutorial we'll go over the basics, we'll connect to an Adafruit Metro 328 = its an Arduino compatible works just like an Arduino UNO R3, and we will connect to an Arduino Leonardo clone. This tutorial we are covering Serial Port Basics on the Arduino Mega 2560 R3.