Physical Computing Week 09

Creating a communication system between two Arduinos

Franziska Mack
Nov 5 · Unlisted

The two Arduinos boards are connected via the RX and TX pins (first Arduino’s TX pin to another’s RX pin and vice versa), ground is connected to ground and 5V to 5V.

Code for the Sender Arduino:

void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("A"),
delay(1000);
Serial.println("B"),
delay(1000);
}

Code for the Receiver Arduino:

int data;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);}
void loop() {
if (Serial.available()){
data = Serial.read();
if (data=='A'){
digitalWrite(13,HIGH);
} else if (data=='B') {
digitalWrite(13,LOW);
}
}
}

Unlisted

Franziska Mack

Written by

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade