//original code by Luis Diaz //Fab Academy 2022 //Fab Lab León //ATtiny412 master I2C //Gothen from http://fabacademy.org/2020/labs/leon/students/adrian-torres/week14.html // Lightly edited by Hafey #include int i = 0; int j = 0; int led = 4; //led pin void setup() { Serial.begin(115200); //speed of the communications Wire.begin(); pinMode(led, OUTPUT); // led } void loop() { for (i = 0; i < 4; i++) { // 0,1,2,3 Wire.beginTransmission(1); //slave number 1 if ( i == 1) { Wire.write(1); Serial.println("1"); } else { Wire.write(0); Serial.println("0"); } Wire.endTransmission(); Wire.beginTransmission(2); //slave number 2 if ( i == 2) { Wire.write(2); Serial.println("2"); } else { Wire.write(0); Serial.println("00"); } Wire.endTransmission(); Wire.beginTransmission(3); //slave number 3 if ( i == 3) { Wire.write(3); Serial.println("3"); } else { Wire.write(0); Serial.println("000"); } Wire.endTransmission(); for (j = 0; j <= i; j++) { // blink i times digitalWrite(led, HIGH); delay(200); digitalWrite(led, LOW); delay(200); } delay(1000); } }