I am trying to accomplish 1-wire communication between 2 Arduinos and so I wanted to start off by having 1 Arduino toggle a digital output pin and have the other read the state of that pin. To accomplish this, I have 2 computers with Arduino IDE installed and each one is connected to one Arduino Uno. Both Arduino Uno's are connected with a single male-male jumper cable on Pin 13 of the header. I am watching the state of the pin by looking at the prints in the Serial Console on both computers.
Here is a diagram of my setup:
Computer1 ---> Arduino1[Sender] --------> Arduino2[Receiver] -----> Computer2
The problem I have is that I am seeing when I first start both Arduinos - the sender is definitely toggling the output pin high->low->high forever - but the receiver Arduino only shows its input pin as toggling for a few seconds and then it gets stuck high. Sometime later, it may go low for 1 iteration, but then sticks at high again. What is going on? I would expect to see the sender and receiver show high->low->high forever. The code seems simple but I must be doing something wrong - thanks for your help.
Sender Code:
int led = 13; // Comm Pin
// Setup pins
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.println("high");
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
Serial.println("low");
delay(1000); // wait for a second
}
Receiver Code:
int led = 13; // Comm Pin
// Setup pins
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Pin is an input - normal state high
pinMode(led, INPUT);
}
void loop() {
// Put your main code here, to run repeatedly:
Serial.println(digitalRead(led));
delay(1000);
}