So I am building a lift system using an Adafruit metro mini. It's supposed to turn some relays on and off when a button is held down depending on the limit switch. Relay1 turns on and stays on for some reason. Relay11 turns on when the limit switch is pressed.
if((digitalRead(buttonInput) == HIGH) && (digitalRead(limit2Input) == LOW){ // both pins are as desired?
// take your action
}
else {
// do nothing - or something else
}
That kind of helped. When I click the limit switches it changes the relay. But the wrong one. If limit 2 is pressed, it turns relay 1 and 2 on. If I click limit 1 it turns relay 11 and relay 22 on. Relay 11 and 1 should go on at the same time and vice-versa. It ignores the button. If i click the button, an led flashes orange.
In the serial monitor it shows 0 for the button until i click, then it shows backwards ? For the limit switch 1 it shows 0 at first and then 1 after i click. But it stays 1. If i click the second limit switch I get 0 until I release. It shouldn't even display the second limit switch.
All relays are on now when nothing is pressed but when i pressed the corresponding limit switch they work as intended. They are ignoring the button for some reason.