Lecture 12 Experiment-16
Lecture 12 Experiment-16
https://linuxhint.com/serial-uart-communication-between-two-arduino/
Serial UART Communication
• While using these two pins for UART It’s important to note that UART pins are specific for a
device itself.
• To establish serial communication using UART between two Arduino boards then the Rx pin of
first board will be connected to the Tx pin of second board similarly Tx pin of first one with Rx
pin of second one.
• Connect two Arduino boards using Tx and Rx pins to establish a serial communication between
them one Arduino board which will transmit data will act as a Master and the second Arduino
board which will receive instructions will act as Slave.
• Setup Arduino boards in Master and Slave configuration.
• To start communication between two Arduino boards, one will be configured as Sender and
other Arduino board as the receiver.
• So, write two programs, one for sender and second for receiver.
Serial UART Communication
Connect Master Arduino
• Using a USB B cable connects the Arduino board which is acting as Master to the PC.
https://linuxhint.com/serial-uart-communication-between-two-arduino/
Serial UART Communication
Connect Slave Arduino
• Using a USB B cable connects the Arduino board which is acting as Master to the PC.
https://linuxhint.com/serial-uart-communication-between-two-arduino/
Serial UART Communication
Connect Both Arduino Using TX and Rx Pins
https://linuxhint.com/serial-uart-communication-between-two-arduino/
Blink LED Using Two Arduino Boards through UART Communication
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print(1);
delay(2000);
Serial.print(0);
delay(2000);
}
https://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/
Blink LED Using Two Arduino Boards through UART Communication
//Receiver (Rx) Arduino Board Code
void setup()
{
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(Serial.available())
{
char serialinput = Serial.read();
if (serialinput =='0') { digitalWrite(LED, LOW); }
if (serialinput =='1') { digitalWrite(LED, HIGH); }
Serial.println(serialinput);
}
}
https://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/
Blink LED Using Two Arduino Boards through UART Communication
https://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/