maximum number of buttons and leds

sorry for the stupid question, but here goes.. :-[

Is it possible to connect lets say, 500 buttons to one Arduino?

if not, what is the maximum number of inputs one Arduino can have?

i´ve heard about Shift Registers, should I look for these IC´s ?

Well, i mean you could possibly do that, yet i am not aware of an ic like that. The arduino diecimila has 20 inputs using a certain program....hope that will help a bit..

For a lot of switches, I would consider using a 'keyboard' with a matrix array instead of trying to build my own. That way you could use serial communication (which uses shift registers).(Keyboard Matrix Help). little-scale: Reading a PS/2 keyboard using Arduino and Picaxe

But for Individually addressed LEDs, that gets a little crazy because of charlieplexing. http://www.instructables.com/id/Charlieplexing-LEDs--The-theory/.

You can use the Arduino's 20 pins to form a 10x10 keypad matrix to get 100 buttons, assuming exactly one button at a time would be pressed. If you need to identify multiple simultaneous button presses, that's a different story.

you can use I/O expanders that use SPI or I2C to add several (usually 8 or 16, but sometimes more) I/O lines at the cost of a few Arduino lines. For instance, if you can deal with surface mount components you could use a pair of MAX7300 (or MAX7301 if you prefer SPI over I2C) expanders to implement your 500 button keypad using scanning techniques.

Just curious, what would you do with 500 buttons?

-j

Thanks,
I think I found what I was looking for:
http://www.arduino.cc/en/Tutorial/ShiftIn

Just curious, what would you do with 500 buttons?

Maybe I was too excited when I wrote this ::slight_smile:
With maybe 50 or 100 buttons and leds, I will try to make a cool game control panel.. :sunglasses:

With 20 IO leads, you can have a matrix of 100 buttons and 100 LEDs by driving the LED matrix in between scans of the button matrix.

With 20 IO leads, you can have a matrix of 100 buttons and 100 LEDs by driving the LED matrix in between scans of the button matrix.

using Shift Register IC right?

driving the LED matrix in between scans of the button matrix.

If you use the row select signals of the LED matrix as row select of the switch matrix you can interleave the multiplexing rather that doing it between scans.

That is, output an LED row and gather in all the switch states in that row before moving on to the next.

using Shift Register IC right?

No, using keypad matrix scanning techniques. Arrange 100 buttons in 10 rows and 10 columns. One set (let's say the row) of lines are outputs, the other inputs. If I set row 0 to high and all others are low, then I will see a high on the corresponding column input if one of those buttons are pressed.

-j

You could use a 74LS165 shift register, it's parallel in and serial out. You would need three lines data, clock and load, but in that way you could look at 8 inputs or more if you cascade them.

BTW, to drive bunches of LEDs, a shift out register is handy

Like using shift in to read lots of buttons, you need shift out to light lots of LEDS.

Also note that you can get several buttons connected to different sized resistors on one analog pin also. AnalogRead will return a value from 0 to 1023 based on the voltage, but I doubt you could add 1000 buttons in this manner and distinguish their individual voltage contributions reliably.

Thank you all for the information!!!

It´s decided to not have more than 100 buttons.

I will get one CD4021BE, and one 74HC595, as soon as possible and start prototyping :slight_smile:

using Shift Register IC right?

No, using a 10x10 LED matrix and 10x10 keypad matrix on the same pins at the same time. No additional hardware is needed, you do it all in software.

If you use the row select signals of the LED matrix as row select of the switch matrix you can interleave the multiplexing rather that doing it between scans.

Interesting idea. I'd never thought of it that way. Would it actually be any better though, your way you have short pauses between rows, my way I have longer pauses between scans, but you'd still have the longer delay before each row gets refreshed.

No, using a 10x10 LED matrix and 10x10 keypad matrix on the same pins at the same time. No additional hardware is needed, you do it all in software.

Sounds interesting!
Can you explain how to make this?
Or give me some guideline to research?

I believe you need to use diodes on your buttons in order to prevent a button press from affecting the corresponding LED.

diodes on your buttons in order to prevent a button press from affecting the corresponding LED.

Yes, also the diodes are needed to stop phantom buttons appearing in the matrix scan. You just use the row drive to drive one side of the button matrix and have the column side of the matrix go into inputs, where as the column side of the LEDs go into current sink outputs.

LEDs are diodes.

to scan the keypad, enable the weak pull-ups on ALL the cathodes of the LED matrix and set them ALL as inputs. In sequence, set the anodes of the LED matrix low. When an anode is not selected to be low, set it as an input. Read if any of the cathode/input lines goes low. If it does, you have the row and column of a button push.

At no point in this will any LED be driven to light. And there is no way you will get a phantom button push. The key is taking advantage of the high-impedence input mode so the line is neither driven low nor high.

If I'm visualizing this correctly, it would still prevent that particular LED from lighting if the button on the corresponding node was being pushed.

Maybe that's acceptable, compared to adding 100 more diodes for a 10x10 matrix.

You also need to verify the reverse voltage rating of your LEDs for all of these approaches.

I´m sorry guys
I think this LED and Button Matrix thing is a bit tricky and advanced to me...

Maybe if you give me a schematic or a drawing of the thing I can follow your conversation

quick question,

do you need to press only one button at a time, or do you need to press several simultaneously?

How about LEDs? Are they also one led at a time or any possible combination or what?