So I am pretty noob to this, this is a noob question as all can be, I can't find the answer by googling.
So I have a two pole button and I wanted to plug this into a digital pin on the arduino. But to get it to register as a 1 I have to route one pole to 5v, which then it stays registered as a 1, to get it to go back and register as a 0 I then have to route the other pole to the ground and push the button. This isn't how I expected it to work. Is there anyway to plug a two pole button into a digital pin on the arduino and have the button push return a 1 and the button release set it back to 0?
That's a poor way to connect it.
Connect 1 leg of button to Gnd, connect the other to a pin, say pin 2 to start.
Then use the internal pullup resistor of the '328P:
byte buttonPin = 2;
byte ledPin = 13; // onboard LED
void setup(){
pinMode (buttonPin, INPUT_PULLUP);
pinMode (ledPin, OUTPUT);
}
void loop(){
if (digitalRead(buttonPin) == LOW){
digitalWrite (ledPin, HIGH); // turn on LED when buttonPin is grounded
}
else {
digitalWrite (ledPin, LOW);
}
} // end loop
SPST is all you need, plus pullup resistor, and software debouncing.
There is a circuit using SPDT and a flip-flop and two pull-up resistors,
and this happens to debounce itself, but that's more hardware to buy - software
debouncing is cheaper.