Im a very very beginner with electronics and arduino. Im humbly saying please dont feel bad on my foolish question may be. Am trying to achieve something like there are 10 push buttons and when pressing or press and holding the buttons Arduino should identify which button it pressed. Is it possible to achive this using single input?? Like adding different resistors to the button out into Arduino Analog in?
Also is it possible to identify which are pressed when all the 10 buttons pressed together or few buttons together. If not what is the solution to accomplish that?
Another question is instead of taking the GND and Power from Arduino board itself, is it OK if I take the power from external supply like a mobile phone charger which is I think 5v. I asked this because if so I can keep the arduino little far from the sensor buttons (Actually they are Reed Switches) .
A resistor ladder is a device used for this, but I suspect with that many inputs that the different between different combinations of buttons will be smaller than the %variance of the construct (like temp variance).
Another option is to use shift registers.
This video looked instructive:
In principle , yes. There are 2^10 or 1024 possible switch combinations of on and off.
One way uses just 11 resistors - 1 value R to ground, other end to an analog input.
Then each of the 10 switches has resistors in series value R, 2R etc up to 1024R connected to this point and other end to a reference supply ( the a/d reference)
Or you could use a R-2R ladder. More practical, but not so easy to understand.
But .
You'd need resistor tolerances of around 0.01% . not cheap.
You can buy all this gubbins with a bit of electronics added as a 10-bit parallel input DAC - but they're not perfect unless you pay a lot.
And the arduino's a/d resolution is only 1024 steps, so you're right on the limit, and almost certain to miss some combinations.
So, in practise, not feasable.
I thnk in practise 5 or 6 switches would be the limit of this approach.
Allan.
ps if you want to save pins a parallel - in serial - out shift register would be useful - such as the 74HC165 which can be daisy-chained as far as you want. Or arrange your switches in a matrix - in your case 5x2 or 3x4 - and scan them , which admittedly only saves you 3 pins.
vinceherman:
A resistor ladder is a device used for this, but I suspect with that many inputs that the different between different combinations of buttons will be smaller than the %variance of the construct (like temp variance).
Thanks a lot for that suggestion. But the ladder part seems to be a bit complicated for me since am a very beginner. But Shift Register is something can I try?
allanhurst:
I thnk in practise 5 or 6 switches would be the limit of this approach.
Allan.
ps if you want to save pins a parallel - in serial - out shift register would be useful - such as the 74HC165 which can be daisy-chained as far as you want. Or arrange your switches in a matrix - in your case 5x2 or 3x4 - and scan them , which admittedly only saves you 3 pins.
So you are suggesting 10 is not so easy.. isnt it?
So I would like to try the shift register method.. ( I bought the same you mentioned.. But dont know much.. what to connect where to connect )..
If you dont mind can you gave me little more details on the matrix method you mentioned at the end
If your issue is I/O pins an I2C port expander may be useful. #include the wire library in your sketch and read up to sixteen switches. Has its own built-in pullups too.
The analogue pins can also be used as normal digital pins.
Leo..
Oh.. Sorry.. You know actually am trying to learn something in electronics.. Im actually a software developer in .NET for the past 12 yrs. But was crazy about electronics but doesnt not anything.. So decided Arduino is a good destination