53. I2C Concepts 1

Question.3

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

 

Master Arduino Code:

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

void loop() {
  Wire.beginTransmission(0xFFF);    
  Wire.write(100); 
  Wire.endTransmission();
  while(1);
}

 

Slave Arduino Code:

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

void loop() {
}

void receiveData(int byteCount) {
  while (Wire.available()) {
    byte receivedData = Wire.read();   
    Serial.print("Slave received: ");
    Serial.println(receivedData); 
  }
}

 

 

 

Select Answer