52. I2C Scenarios

Question.3

What will be printed on the Master’s Serial Monitor? (after executing the following codes)


Master Arduino Code:

#include <Wire.h>
void setup() {
  Serial.begin(9600);
  Wire.begin();
}

void loop() {
  if (Wire.available()) {
    byte receivedData = Wire.read();
    Serial.print("Received Data: ");
    Serial.println(receivedData);
  }
}

Slave Arduino Code:

#include <Wire.h>
void setup() {
  Wire.begin(8);
  delay(2000);
}

void loop() {
  Wire.write(42); 
  while(1);
}

 

Select Answer