Question.3
What will be printed on the Master’s Serial Monitor?
Master Arduino Code:
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
Wire.setClock(400000);
delay(1000);
}
void loop() {
Wire.requestFrom(8, 1);
Wire.setClock(100000);
while (Wire.available()) {
byte receivedData = Wire.read();
Serial.print("Received data: ");
Serial.println(receivedData);
}
while(1);
}
Slave Arduino Code:
#include <Wire.h>
void setup() {
Wire.begin(8);
Wire.onRequest(sendData);
}
void loop() {
}
void sendData() {
Wire.write(100);
}