i have 2 arduino r4's. i want these 2 boards to communicate witch each other over i2c. I first connected the 2 boards with digital pins. I later found out that this is not possible because they dont have a pullup. So now i have connected the 2 boards with a qwiic connect cable. i am using the wire library to connect between the 2, but nothing happens. i am using the example code from the wire library, to make sure there's nothing wrong witht the code. I only eddited the Wire to Wire1. Nothing happens when i connect the boards and upload the code. Can anyone help me with this?
the master code:
#include <Wire.h>
const int SLAVE_ADDRESS = 4;
// Set up the I2C bus
void setup() {
Wire1.begin();
}
// Send a message to the slave Arduino
void loop() {
Wire1.beginTransmission(SLAVE_ADDRESS);
Wire1.write("Hello from the master!");
Wire1.endTransmission();
// Delay for 1 second
delay(1000);
}
The slave code:
#include <Wire.h>
// Set up the I2C bus
void setup() {
Wire1.begin(4);
Wire1.onRequest(requestEvent);
}
// Receive a message from the master Arduino and print it to the serial monitor
void requestEvent() {
int bytesReceived = Wire1.requestFrom(10, 255);
while (bytesReceived > 0) {
Serial.print(char(Wire1.read()));
bytesReceived--;
}
Serial.println();
}
// Loop forever
void loop() {}
