I have made a project by using an arduino board and an ethernet shield. Its working well except that I need about 20-30 buttons connected to the board.
What is the best way to solve this problem? I have tried to look at shift registers but mostly have come across where they are used to control leds in tandom.
Have a look at the 74HC4067, a 16 channel multiplexer/demultiplexer. You'll need 6 pins on your Arduino (and a transistor) to drive 2 of them, giving you 32 inputs.
4 pins for the address
1 pin for chip select (using the transistor to invert to one enable pin & non-invert to the other enable pin.)
1 pin for input
Four 74165 parelell in srerial out shift registers daisy chained together will interface 32 switches using 3 pins. Latch the switch states and use shiftIn() to read the registers.
rm65453:
any pros and cons between using the 74HC4067 vs the 74165 approach mentioned above.
Well, the 74HC165 x 4 (note: incorrectly quoted without the essential "HC") uses fewer pins on the Arduino, is simpler to program and probably cheaper, but requires four resistor arrays as pull-ups while the 74HC4067 requires only one resistor - or none if you use the internal pull-up on the Arduino. Resistors are trivial; go for the 74HC165.
If you just need to press one button at a time(no two key roll over) you can use the extended charlieplexing. 25 buttons require 5 pins and 10 cheap diodes. The coding is a little bit more tricky but it should be possible if you give you some time to study this example: Extended Charlieplexing - LEDs and Multiplexing - Arduino Forum