int sig = 2; // Pin to read the signal from
void setup() {
Serial.begin(115200); // Initialize serial communication
pinMode(sig, INPUT_PULLUP); // Configure pin 2 as input with pull-up resistor
Serial.println("ESP32 Sender Initialized.");
}
void loop() {
int signalState = digitalRead(sig); // Read the state of pin 2
if (signalState == HIGH) {
Serial.println('0'); // Send '0' when signal is LOW
} else {
Serial.println('1'); // Send '1' when signal is HIGH
}
delay(100); // Add a small delay to ensure the receiver processes data correctly
}