4 buttons on one digital IO

Is this a good idea?

I have a limited number of digital IOs i can use and id like to use just one digital pin for 4 buttons. My idea is to use a 555 timer to output a specific frequency for each button based on the unique resistor value that is attached to each button. Then sense that frequency and instead of sensing a pin high or low.

Something like this WiringDiagramCircuit.com is for sale | HugeDomains but with 4 button connected to 4 resistors instead of a pot.

So you're thinking have the buttons pressed in parallel so the resistance is seen as changing depending on the combination of resistances presented? That would work.
4 button could yield 16 combinations if the resistors are sized correctly.
(like 1K, 2K, 4K, 8K)

Whilst your idea is feasible, there are easier ways of reading several buttons through a smaller number of pins. What are you using all the other pins for? I often use a single pin to read several buttons, by getting some output pins - such as pins for an LCD - to double up as multiplex pins.

I assume you realize that you can use the analog pins as digital pins.

dc42:
I assume you realize that you can use the analog pins as digital pins.

Or even use them as analog pins - to connect several buttons, each with a different resistor, and measure the voltage when you press one of them.

I don't think he wanted to read the value - just have a different resistance presented to a 555 timer to change its output.
Then pulseIn() could be used to read the result & make a decision.

CrossRoads:
So you're thinking have the buttons pressed in parallel so the resistance is seen as changing depending on the combination of resistances presented? That would work.
4 button could yield 16 combinations if the resistors are sized correctly.
(like 1K, 2K, 4K, 8K)

Yeah, exactly. But i hadnt thought about the simultaneous press condition, i was just thinking about one button at a time. But if i take into account the combinations then that would work too! cool.

dc42:
Whilst your idea is feasible, there are easier ways of reading several buttons through a smaller number of pins. What are you using all the other pins for? I often use a single pin to read several buttons, by getting some output pins - such as pins for an LCD - to double up as multiplex pins.

I assume you realize that you can use the analog pins as digital pins.

I need all my digitals to control a non serial LCD, SD card, status LEDs... and i need all my analog pins for reading sensors (well maybe ill have one extra, we'll have to see). I could use a multiplexer on the analogs, but the 555 with resistors i can buy in town. How do you use an pin for both LCD and a multiplexer?

fungus:
Or even use them as analog pins - to connect several buttons, each with a different resistor, and measure the voltage when you press one of them.

If i end up having one extra analog maybe ill do that, that would be even simpler.

jonwwo:
I need all my digitals to control a non serial LCD, SD card, status LEDs…

Then you can multiplex your switches (up to 5 of them) into a single digital pin, using one small signal diode per pin, with up to 5 of the LCD pins (all except the Enable pin) doubling up as multiplex pins. See schematic. Enable the internal pullup resistor on the pin that the switches are connected to. To read the switches, first set all the LCD data pins and the RS pin high. Then take one of those pins low and read the input. If the input reads low, then the associated switch (connected to that pin by a diode) is closed, if it reads high then the switch is open. Take the pin high again, and repeat for the other pins.

jonwwo:
I need all my digitals to control a non serial LCD

You could use a shift register for the parallel output to the screen (eg. 74HC595).

With the pins you gain you can add another shift register for input, add 8 buttons and still have some I/O pins left over.

Add a shift register, add a 555, add something. The only non-add is using an analog input.

Or step up to a chip with 12 more IO: 2 analog inputs, and 10 digital IO.
http://www.crossroadsfencing.com/BobuinoRev17/

A shift register would only require 3 pins. Not to mention that you can use your extra analog pins as regular digital pins.

Example: digitalWrite(A0, HIGH);

Also, you can link more than one shift register together while only using the same three pins.