Try to write a simple sketch that reads from the GPIO pin you’re using and prints the result. This will confirm whether the pin is properly reading the state or if the issue is with the hardware setup.
void setup() {
Serial.begin(115200);
pinMode(4, INPUT); // Replace with your actual pin
}
void loop() {
int val = digitalRead(4); // Replace with your actual pin
Serial.println(val);
delay(500);
}