HUNDREDS OF PUSH BUTTONS WITH ONE PIN - Arduino

8.4K1008

Intro: HUNDREDS OF PUSH BUTTONS WITH ONE PIN - Arduino

Don't waste more pins in buttons!

STEP 1: INTRO

The idea is simple. Use the analog pin A0 for read different push buttons with different resistance values. Then is about setting an interval for each button to use each one.

I prefer to use pull down resistors which force LOW when the button is off, and prevent from strange analog reading values.

STEP 2: CIRCUIT

You can put as many buttons as you need with different resistors.

STEP 3: Calibrate

For this step you have to associate each button for each analog read value of arduino. You could use a multimeter or the following sketch.

As the Arduino IDE doesn't allows you to create .txt files, just copy the interval (ctrl+C) from the serial monitor for then use them in your program.

8 Comments

You cannot detect multiple pushes. Anyway this can't be used for prof devices due to the lack of accuracy and the sensivity to noises. I guess you know these solutions were explored far behind digital processes.

It's not exact, because this approach can surely detect more than just one switch closed. Obviously that if we want get this capability, we need to chose the value of the resistors with an amount of complexity.

Anyway, just to have an idea, with 4 switches we can combine only 16 values zero included. If we want use this way with 5VDC, we need to appreciate 15 step of 0.33V.

Further, I think that can be useful to consider the possibility to push 2 at maximum switch together.

More than 2 switches closed, appears to me as very little useful in this case, so the number of combination decrease from 16 to 12.

this is true. while you cannot detect multiple presses, this would be a nice easy solution for a rotary switch. as has been said, multiple presses would give some strange results. if you thought about it, you may be able to make some kind of a puzzle game, where multiple presses are required! good luck.

One way to simplify this is to use the DAC arrangement, instead of switching in resistor dividers like here, you would put a bunch of resistors in series and in between each resistor have a switch to ground. All resistors can be the same value, in that case, and the analog values would end up more consistent.

I saw an instructable that used that arrangement with a 555 timer to make a simple synthesizer, each button would play a different pitch.

You must remember that afte rsome time switches can gain their own resistance (on contact), so when you push one switch, it can be read as another one.

This is wonderful. I did not think about this. what a clever fix.