Simple question: Multiple pushbuttons...diagram?

i've looked at the pushbutton tutorial, and got confused... I need to connect 6 buttons to the arduino, and want to use as few components as possible... can anyone draw me a diagram?

You can get by with just the 6 push buttons. Connect each push button to ground on one side and a digital pin of the Arduino on the other. (Be aware, if your button has 4 pins then they are really two copies of each pin, you have to get a pin from each pair or your button will be "always pushed").

That will take care of pulling the pin low when you push the button, to pull it high otherwise you need to use a pull-up resistor, but you don't need a new one, there is one built into the ATmega chip in your Arduino. Proceed as in the push button tutorial, but add a line to the setup() function...

void setup() {
  pinMode(ledPin, OUTPUT);  // declare LED as output
  pinMode(inPin, INPUT);    // declare pushbutton as input
  digitalWrite(inPin,HIGH); // turn on its pull-up resistor
}

Yes, we did just write to an input pin, but that's ok. That turns on the pull-up resistor.

(Be aware, if your button has 4 pins then they are really two copies of each pin, you have to get a pin from each pair or your button will be "always pushed").

THANK YOU! I probably thought of at least a hundred different ways 4 pins could be used yesterday!

Do the buttons have to be pulled high after each use?? My code is acting like the button remains held down after it has been released.

never mind, I pulled a bonehead move and mixed N.O. and N.C switches.... duh

Hi Folks,

I read with great interests on this topic regarding multiple pushbuttons.... as we are currently exploring on a project to interface with 40 key pads (3 push-buttons on each pad). Each key pad would offer 3 choices of selection to the user...

My question is can Arduino be used for my needs? As I understood, Arduino has up to 13 digital I/O and in this case do I need more than 1 Arduino unit? If so, can Arduino be "daisy chained"?

Actually, to further complicate the matters, we wanted to use illuminated push buttons for this purpose. The LED in the buttons would just toggle on/off when push on during the stage when the user does not need to make any choice.

At the stage when the choice needs to be made (with a given duration), the button's LED light would be on when push. But the 3 buttons would toggle between themselve, that is:

  1. No choice Selected (All Buttons OFF)
  2. Button A pushed (Button A Lighted)
  3. User decide to push Button B, then Button B lighted and Button A goes off (so on and so forth between A, B & C)

Can Arduino support my needs here?

Thank you for your kind attentions....

You will need to expand the number of inputs and outputs. The most common way is to use shift registers. There is an example of using a shift register LED driver at http://www.arduino.cc/en/Tutorial/LEDDriver which should handle your LEDs. (You can connect 15 shift registers end to end and not take any more pins from the Arduino. You just shift 120 bits before you latch the data.)

There are similar shift registers for inputs. There is an example of that at http://www.arduino.cc/en/Tutorial/ShiftIn. That example even has a nice diagram of the daisy chaining.

In addition to the shift registers you might be able to get by with fewer external parts by using a 4-to-16 demultiplexer (4 pins could control 16 columns) with 9 pins for (3 keypads per column).

You would use the demultiplexer to control the ground line of the key pads and scan 1 column of 3 keypads at a time.

This would be one external chip plus the arduino. You could even use the analog pins for digital io if you need a couple of extra i/o lines.

There will be aliasing issues with this approach where pressing groups of keys would cause phantom keys.
Say your columns are identified by letters A-P and your rows are digits 0-9. If you press A0, B0, and B1 concurrently then strobe A to see which digits it shows up on, it will show up on 0 and 1 because it can sneak through the A-0-B-1-A path. Darn those electrons. You can put a diode in series with each switch to stop these paths.

If only there was the inverse of the MAX7219, i.e. 8x8 inputs rather than outputs!

The 7219 is awesome, 3 pins to control 68 LEDs!!! Surely the market is there for a chip to do 8x8 inputs using a single chip!

I've seen the 74C922 4x4 kepad encoder, but (here is Australia at least) it is damn expensive, like AU$10. Using four of them to make a 8x8 keboard matrix would be too expensive, and use too many lines.

The playground example using two 4051s Arduino Playground - 4051 looks promosing, but still a bit more complicated than the ideal.

Any other ideas?

Hi

Holtek makes keyboard encoders, check this link. It would take some codign to make it work, but it is a one-chip solution, encoding up to 109 keys. Alternately you could just hack an IBM pc serial style keyboard: first get the Arduino code and interface going correctly, then cannibalize the keyboard to replace the switches with your buttons.

D

Alternately you could just hack an IBM pc serial style keyboard: first get the Arduino code and interface going correctly, then cannibalize the keyboard to replace the switches with your buttons.

D

Damn! I didn't realise someone had done all the hard work to interface with a PS/2 part. That's awesome...

Combining all this sort of seems like a Monome "Lite" version might be possible... would be awesome. Of course the silicone keypads they use aren't cheap...

I agree that the cost of thepush buttons is buttons is high. I wish somebody had/sold a 4x4 board using one of these: http://www.qprox.com/products/qt60xxx.php
that was designed so that you could connect multiple 4x4 board's together with additional hardware/processing. It would also be cool if the board was built to accommodate LEDS for each button(although to keep the top side flat I suppose there would have to be holes cut on the board with the LED mounted on the back side). Unfortunately, due to the package size there's no way I could lay the board out and build it...

:frowning:

-B