Hello and thank you all! Here are my codes:
Arduino Master:
#include <Wire.h>
int counter = 0;
void setup() {
Wire.begin();
}
void loop() {
Wire.beginTransmission(1);
Wire.write(counter);
Wire.endTransmission();
counter++;
delay(1000);
}
Arduino Slave:
#include <Wire.h>
int val = 0;
void setup() {
Serial.begin(9600);
Wire.begin(1);
}
void loop() {
val = Wire.read();
Serial.println(val);
delay(1000);
}
My problem is that the serial monitor only prints -1 repeatedly, indicating that I'm not receiving any data (I had a while loop waiting for serial data (Wire.available()==0) but got rid of it because there was no printing going on period.
I think it might be a physical configuration thing:
I have both the A5 pins connected to a rail on my breadboard, which is connected to high via a 10k ohm resistor.
I have both the A4 pins connected to a rail on my breadboard, which is connected to high via a 10k ohm resistor.
I have the ground pins on my two Arduinos connected to each other.
I have a ground pin from my slave Arduino connected to my breadboard.
I have one 5V output pin from my slave Arduino connected to my breadboard