Offline
Newbie
Karma: 0
Posts: 23
|
 |
« on: April 15, 2012, 03:47:28 am » |
Hi,
pobably the solution is already posted in the forum but I couldn't find it.
I have 10 buttons but only 7 digital Pins (no analog in or output is left). They will not be pressed at the same time.
It should be possible to code these buttons onto 4 pins (16 possible combinations) or even in serial. I thought about using diods to code them. But maybe there is a nicer solution. What would you use? Maybe a shift register or some kind of IC?
Do you have an recomendation or example?
|
|
|
|
|
Logged
|
|
|
|
|
Firenze, Italy
Offline
Full Member
Karma: 0
Posts: 102
Dislessia portami via
|
 |
« Reply #1 on: April 15, 2012, 04:13:38 am » |
I guess using two shift register like the 74hc595 and four buttons. But I'm a pretty NooB with electronics 
|
|
|
|
|
Logged
|
The brightest flame burns quickest
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #2 on: April 15, 2012, 04:47:22 am » |
3 x 4 matrix?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Full Member
Karma: 3
Posts: 207
|
 |
« Reply #3 on: April 15, 2012, 08:40:59 am » |
A very simple solution is to use a voltage divider. Switches (buttons) are connected to points on the divider and the voltage on the output of the switch is read using analogRead. That value is mapped to a value of the number of switches you have then switch case is used for control. A helpful previous post: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1226896251- Scotty
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 90
Posts: 9401
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #4 on: April 15, 2012, 09:05:03 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #5 on: April 15, 2012, 10:53:43 am » |
Yes, a matrix would be easy and it will work. Just create a simple truth table for your pins and have the Arduino read the pins as inputs( of course). If the input pins equal X then it must be button X that was pressed. BCD basically. I'm doing it with a dip switch right now on a project I built. It reads the dip switch and determines a fixed time for a timing cycle.
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 131
Posts: 4679
|
 |
« Reply #6 on: April 15, 2012, 11:46:46 am » |
Wire your buttons in a 3x4 matrix, then use the keypad driver to read them. See http://www.arduino.cc/playground/Code/Keypad.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13897
Lua rocks!
|
 |
« Reply #7 on: April 15, 2012, 04:22:29 pm » |
A very simple solution is to use a voltage divider. Switches (buttons) are connected to points on the divider and the voltage on the output of the switch is read using analogRead.
--> ... (no analog in or output is left).
Similar to the suggestion about the shift register you can use a port expander for around $5: http://www.gammon.com.au/forum/?id=10945Also the keypad idea should work.
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25508
Solder is electric glue
|
 |
« Reply #8 on: April 15, 2012, 04:46:38 pm » |
(no analog in or output is left). Arduinos do not have analogue outputs. Or even analog outputs.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13897
Lua rocks!
|
 |
« Reply #9 on: April 15, 2012, 05:49:25 pm » |
Don't forget analogWrite Mike.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 23
|
 |
« Reply #10 on: April 18, 2012, 05:05:27 pm » |
Wow thank you guys! Does anyone have a example how to use a shift register? This matrix thing sounds greate. I think this is what I'm gona use.
@Nick: Ok. I mean an PWM output. Sry for my bad wording.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13897
Lua rocks!
|
 |
« Reply #11 on: April 18, 2012, 05:16:49 pm » |
Shift register for output: http://www.gammon.com.au/forum/?id=11518I don't have an input example but I'm sure a search will show one up.
|
|
|
|
|
Logged
|
|
|
|
|
Toronto, Canada
Offline
Edison Member
Karma: 2
Posts: 1233
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
|
 |
« Reply #12 on: April 18, 2012, 10:45:52 pm » |
Does anyone have a example how to use a shift register?
Yes. Here : http://www.arduino.cc/en/Tutorial/ShiftIn
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25508
Solder is electric glue
|
 |
« Reply #13 on: May 05, 2012, 03:27:38 pm » |
Don't forget analogWrite Mike. I have not, it dosn't change the fact that analogWrite produces a digital output not an analogue one. OP - if you use the shift out tutorial then don't fit the capacitor on the latch pin. That is an error, but no one will change it.
|
|
|
|
|
Logged
|
|
|
|
|
Wisconsin
Offline
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #14 on: May 06, 2012, 01:51:46 am » |
Just use a demultiplexer!
the way they work is you hook up the switches to the demultiplexer and then you hook that up to the arduino (or whatever is controlling it) and then when you press a button, the demux spits out what pin that the signal is coming from. And then just use software to chose the proper path for the switch using if statements.
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
|