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.

The code
// 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);
}
}
}
More like this

Nano blink
The same Blink on an Arduino Nano, its LED on D13.
ArduinoArduino Nano

Two Unos over I2C
Board 1 is the I2C controller (Wire.begin()), board 2 a target at address 8 (Wire.begin(8)). Board 1 sends its knob ten times a second; board 2 sets its LED to it and answers how many it has had.
ArduinoArduino Uno

Pro Mini: blink
The Pro Mini’s real ATmega328P blinks LED 13 and counts its uptime.
ArduinoArduino Pro Mini