First I tried a serial communication between two Arduino unos through the serial ports (RX and TX). The schematic below shows how I connected them together.
The TX goes to RX and RX goes to TX, also there has to be a common ground between the two or else it will not function properly.
For Master board I used the following code to sent "H" to turn on the Slave board's led for 1 sec , and sent "L" to turn off the Slave board's led for 1 sec
//Master
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
}
For Slave board I used PhysicalPixel Example to obtain the information from the serial port and turns on the LED if it gets "H", and turns it off if it is "L".
/*
Physical Pixel
created 2006
by David A. Mellis
modified 30 Aug 2011
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/PhysicalPixel
*/
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
}
I wanted to try a serial communication between Neil's bridge board and Arduino Uno.
First I fabricated the bridge board.
Then programmed it to send "H" to turn the Arduino's Led (ON), and send "L" to turn the Arduino's Led (OFF).
#include < SoftwareSerial.h >
SoftwareSerial mySerial (3,4); // (TX,RX)
void setup() {
mySerial.begin(9600);
}
void loop() {
mySerial.println('H');
delay(1000);
mySerial.println('L');
delay(1000);
}
Then made the connection between the bridge and the slave Arduino I used before. The TX goes to TX and RX goes to RX, also there has to be a common ground between the two or else it will not function properly.
This work by Joseph Gourgy is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.