#include #include const int buttonPin = D1; bool lastButtonState = HIGH; // Receiver MAC address: DC:DA:0C:17:81:D4 uint8_t receiverMac[] = {0xDC, 0xDA, 0x0C, 0x17, 0x81, 0xD4}; void setup() { Serial.begin(115200); pinMode(buttonPin, INPUT_PULLUP); WiFi.mode(WIFI_STA); if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } esp_now_peer_info_t peerInfo = {}; memcpy(peerInfo.peer_addr, receiverMac, 6); peerInfo.channel = 0; peerInfo.encrypt = false; if (esp_now_add_peer(&peerInfo) != ESP_OK) { Serial.println("Failed to add peer"); return; } } void loop() { bool buttonState = digitalRead(buttonPin); if (buttonState != lastButtonState) { uint8_t data = buttonState == LOW ? 1 : 0; // LOW means pressed esp_err_t result = esp_now_send(receiverMac, &data, sizeof(data)); if (result == ESP_OK) { Serial.print("Sent: "); Serial.println(data); } else { Serial.println("Send Error"); } lastButtonState = buttonState; delay(50); // debounce   } }