ArduinoArduino UnoExact chip

Two Unos over serial

Two boards, each with its own program: the first sends "ping" every half second, the second toggles its LED and answers "pong". Pick a board above the code to see its program; its serial monitor has a tab.

Two Unos over serial in Argynix Lab

The code

sketch.inoC++
// Board 1: sends a numbered ping on its TX (pin 1) every half second, and prints
// what the other board answers on its RX (pin 0).
int n = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.print("ping ");
  Serial.println(n++);
  delay(500);
  while (Serial.available()) {
    String reply = Serial.readStringUntil('\n');
    reply.trim();
    if (reply.length()) {
      Serial.print("Board 2 says: ");
      Serial.println(reply);
    }
  }
}