I can’t see the change by the input on the pendant, maybe I don’t know the right place to observe it.
The Program on the Teach-Pendant is just starting when I pressed “play“.
I now switched NC to NO and it’s not starting anymore.
It’s like the relay is not changing its state right. But the PWR LED (and Arduino LED) is lighting up when I press the button.
I can’t upload the Video…
But here is my Arduino Code.
// 05-12-2025
// Kurzhubtaster (Push-Button) mit Debouncing und Toggle-Funktion
const int buttonPin = 2; // Push-Button (gegen GND)
// Debounce-Variablen
unsigned long lastDebounceTime = 0;
const unsigned long debounceDelay = 50;
bool lastButtonReading = HIGH; // letzter roher Tasterwert
bool buttonState = HIGH; // entprellter Tasterwert
bool toggleState = false; // EIN/AUS-Zustand
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// --------------------------
// BUTTON DEBOUNCE
// --------------------------
bool reading = digitalRead(buttonPin);
// Zustand hat sich geändert → Entprell-Zeit starten
if (reading != lastButtonReading) {
lastDebounceTime = millis();
}
// Wenn der Zustand stabil ist …
if ((millis() - lastDebounceTime) > debounceDelay) {
// … und sich der entprellte Zustand ändert …
if (reading != buttonState) {
buttonState = reading;
// BUTTON wurde gedrückt (LOW) → Toggle umschalten
if (buttonState == LOW) {
toggleState = !toggleState;
if (toggleState) {
Serial.println(“Toggle = EIN”);
} else {
Serial.println(“Toggle = AUS”);
}
}
}
}
lastButtonReading = reading;
// (Hier kann eine Aktion ausgeführt werden,
// abhängig von toggleState)
}