#include const int ledPin2 = 2; const int slave_address = 0x01; byte x = 1; byte estado = 0; void setup() { // Initialize Serial port Serial.begin(9600); Serial.println(); Serial.println(F("--------------------------------")); Serial.println(F("Networking and Communications (MASTER)")); Serial.println(F("--------------------------------")); Wire.begin(); // join i2c bus (address optional for master) //pinMode(ledPin2, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); } void loop() { //Transmition Wire.beginTransmission(1); // transmit to device #1 Wire.write(6); // sends one byte // Enviamos un byte, L pondrĂ¡ en estado bajo y H en estado alto Wire.write(estado); if(Wire.endTransmission() != 0){ // stop transmitting Serial.print("ERROR de comm"); } else if(Wire.endTransmission() == 0){ Serial.print("Sent!"); digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); } digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW // Cambiamos el estado if (estado == 0) { estado = 1; } else { estado = 0; } //Reception /*Wire.requestFrom(slave_address, 1); // request 6 bytes from slave device #8 while (Wire.available()) { // slave may send less than requested char c = Wire.read(); // receive a byte as character Serial.print(c); // print the character }*/ }