//Wired Master
#include <Wire.h>

int BUTTON1 = D10;
int BUTTON2 = D8;
int LED = D9;

void setup() {
  Wire.begin(); 
  pinMode(BUTTON1, INPUT);
  pinMode(BUTTON2, INPUT);
  pinMode(LED,OUTPUT);
  Serial.begin(9600); //Initializes serial communication
}

void loop() {
  //Read buttons
  int STATE1 = digitalRead(BUTTON1);
  int STATE2 = digitalRead(BUTTON2);

  if(STATE1 == LOW){
    digitalWrite(LED,LOW); //Turn off LED
    Wire.beginTransmission(8); //Begin communitacion with address of slave 1 (wired)
    Wire.write('0'); //Send 0 to the wired slave
    Wire.endTransmission(); //End transmission with wired slave
    Serial.println("Wired: 0"); //Print in serial monitor
  }
  else if(STATE1 == HIGH){
    digitalWrite(LED,HIGH);
    Wire.beginTransmission(8); //Begin communitacion with address of slave 1 (wired)
    Wire.write('1'); //Send 1 to the wired slave
    Wire.endTransmission(); //End transmission with wired slave
    Serial.println("Wired: 1"); //Print in serial monitor
  }
  delay(100);
}