Best way to wire up multiple push buttons

Hello all,

I'm working on a simple project which will have 3 push buttons. I'm hoping people could share with me their recommended ways of handling multiple inputs from buttons.

I've done some experimentation with interrupts and was thinking this was the best way, I also wanted to wire it in such a way that I only had to use a single interrupt pin (since there are only two available on my Arduino). However, I've not had much luck.

Here is how I've wired things up..

switch 1 was wired to pin 2 and 3
switch 2 was wired to pin 2 and 4

My thinking was when a button was pressed the interrupt would fire and I could just read each pin to see which button fired the interrupt, but instead when I press any button, both pins read high :\ I'm convinced it to do with how I've wired things but I could have been thinking on the wrong lines completely.

Sorry if I've missed some detail, I'll try and get a proper diagram (can anyone recommend software which will run on Ubuntu?)

Cheers
marclurr

No need to use interrupts. Just wire each button to a +5V and a single digital input pin and read them in loop().

I considered this but I was missing button presses. My experiment was a switched which toggled between two modes on an LED. One mode flipping the pin then waiting 500ms (thus making a blinking light) but unless you held the button down (or pressed it at exactly the right time) it missed the press. When I modified the code to use the interrupt I didn't get this behaviour.

Is there a way to, for want of a better phrase, not miss button presses without using interrupts?

Cheers

The issue is your use of delay. Check this out: http://arduino.cc/en/Tutorial/BlinkWithoutDelay

Ah hah! Thanks very much! It never occurred to me to do the blink timing myself. This has helped me a lot :slight_smile: