#include #define slave1_ADDR 0x9 //#define slave2_ADDR 0x8 int LED=15; int BUTTON=14; int previousButtonState=0; int ButtonState=0; void setup (){ Wire.begin(); //Serial.begin(115200); pinMode(LED, OUTPUT); pinMode(BUTTON, INPUT); pinMode(22, OUTPUT); pinMode(21, OUTPUT); } void loop(){ ButtonState = digitalRead(BUTTON); if (ButtonState != previousButtonState) { previousButtonState=ButtonState; if(ButtonState==0){ digitalWrite(LED, HIGH); //Serial.println("encender"); Send_Button(); }else if(ButtonState==1){ // Serial.println("apagar"); digitalWrite(LED, LOW); Send_Button(); } } } void Send_Button(){ if(ButtonState==0){ Wire.beginTransmission(slave1_ADDR); Wire.write(1); Wire.endTransmission(); delay(100); } else { Wire.beginTransmission(slave1_ADDR); Wire.write(0); Wire.endTransmission(); delay(100); } /*Wire.beginTransmission(slave2_ADDR); Wire.write(1); Wire.endTransmission(); delay(1000);*/ }