You could use the software serial library on each arduino, and a couple of wires between them on two different pins (one for transmit, the other for receive) - for instance:
On Arduino1, run a wire from pin 2 to pin 3 on Arduino2; then run a wire from Arduino1 pin 3 to Arduino2 pin 2.
Then code on Arduino1:
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
void setup() {
// setup software serial for output
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(9600);
}
void loop() {
mySerial.print("X");
}
Then code on Arduino2:
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
void setup() {
// setup software serial for input
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(9600);
// setup hardware serial port
Serial.begin(9600);
}
void loop() {
char someChar = mySerial.read();
Serial.println(someChar);
}
Your USB cable should be hooked to Arduino2 to see the output of the hardware serial port (the above should work - but I haven't tested it, its all "off the cuff"). You can find more information on SofwareSerial here:
Hope this helps...
![]()