#include // Constants for pin assignments const int buttonPin = 26; // Assuming D1 maps to GPIO 26 const int ledPin = 22; // Assuming the first LED is on GPIO 22 void setup() { pinMode(buttonPin, INPUT_PULLUP); pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); Serial.begin(9600); // For debug output to the Serial Monitor Serial1.begin(9600); // UART communication Serial.println("Setup complete - RP2040"); } void loop() { // Check if the button is pressed if (digitalRead(buttonPin) == LOW) { Serial.println("Button pressed - Sending '1'"); Serial1.write('1'); // Send '1' to turn on LED on ESP32-C3 delay(200); // Debounce delay } // Listen for incoming commands to control the LED if (Serial1.available()) { char cmd = Serial1.read(); Serial.print("Received command: "); Serial.println(cmd); if (cmd == '1') { digitalWrite(ledPin, HIGH); // Turn on the LED when '1' received delay(500); digitalWrite(ledPin, LOW); } } delay(100); // Short delay to avoid flooding with serial data }