-->
Page 1 of 1

Solution verification of wiring for 9 button setup

PostPosted: Sun Jul 23, 2017 5:30 pm
by konduktorn
Problem/Background:

Using the Adafruit ESP8266 Feather HUZZAH, I need support for at least 9 buttons/switches - preferably using a single IO-pin on the board. Being completely green in regards to basic circuit theory and wiring design, my schematic is based on the first answer in the following post: http://www.esp8266.com/viewtopic.php?p=61392#p61392.

Given that we read which button is pressed using the analog ADC-pin (which supports voltages in the range [0.0, 1.0]), with a source power of 3.3V supplied by the 3V-pin - the voltage over the ADC-pin must be divided into suitable segments to achieve an unambiguous reading for each of the 9 buttons.

Solution(?):

Given ideal resistors,
Code: Select allV_out = V_in * R_2 / (R_1 + R_2)
V_out = 1.0V, V_in = 3.3V
1.0V = 3.3V * R_2 / (R_1 + R_2)


With
Code: Select allR_2 = 22k
R_1 = 9k

We get
Code: Select allV_max = 0.96 = 3.3 * 22000 / (9000 + 22000)


Dividing R_1 evenly for the 9 buttons, we get
Code: Select allR_1 / 9 = 1k Ohm

per button/switch, so that pressing 'button 1' would yield 0.14V and pressing 'button 9' would yield 0.96V.

I've attached a screenshot for the wiring explained above - but it looks a bit weird to me, and being a newbie I don't really trust myself. Please feel free to comment on any or all misstakes and unnecessary steps you can find in the description or screenshot.


You can also find the attached fitzing file 'msi.fzz' in case you would like to make any adjustments to the schematics/wiring.

Any suggestions and tips are much appreciated!

Screen Shot 2017-07-23 at 23.34.36.png

Re: Solution verification of wiring for 9 button setup

PostPosted: Sun Jul 23, 2017 10:55 pm
by rudy
Your diagram is wrong. All the resistors are connected to the same strip. All shorted together. You need to move them into the center section. Sorry but I don't have time to show you the fix right now.

Re: Solution verification of wiring for 9 button setup

PostPosted: Tue Jul 25, 2017 8:05 pm
by QuickFix
Schematically it should look like this (I'm always having problems "Reading" bread boards and am doing it "The old way"): ;)
Image

I'm not sure using ADC is a perfect solution, but it won't cost you any GPIO's, so that's a plus.
If you can spare 2 GPIO's you can also opt for an I2C solution with, for instance, a MCP23017:
Image