#include const int endSwitchPin = 2; // Replace with the actual GPIO pin you're using void setup() { pinMode(endSwitchPin, INPUT_PULLUP); // Set the pin as input with internal pull-up resistor Serial.begin(9600); } void loop() { int switchState = digitalRead(endSwitchPin); if (switchState == LOW) { Serial.println("End switch is pressed."); // Perform your desired action here } else { Serial.println("End switch is not pressed."); } delay(100); // Optional debounce delay }