Pages: [1]   Go Down
Author Topic: Settings switches  (Read 575 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm fairly new to this whole Arduino thing to be honest.
To be more honest, I have nearly no robotic experience at low-level.

(Which is why I chose Arduino; seemed friendly enough!)

Basically, in an attempt to use less I/O pins, I want to rely on an Uno board rather than a Mega. My problem is, I can think of only a very primitive way to use input pins.

My current problem is that I need a set of 8 switches (well, not need, but it seems best) for the software to decide what to do. The first 3 bits shall be used for which program to run (2^3 = 8 separate programs). The remaining 5 bits will be used for various other boolean settings.

Now the statement of the problem: I don't want to use 8 different pins. Especially, when considering digital terms, that's just a byte.

I'm a software guy. Low-level programming thrills a little part of me. I'm just not used to the hardware end of things.

If anyone has pointers to introductory I/O tutorials, hints, or hardware optimizations and methods, I would very much appreciate them!

Thanks for any replies that come in, and for your time in writing them!

PS: I'm fairly sure this is in the right subforum. It -could- go under software, but I have far more problems on th hardware side. I can deal with software mostly by myself.
Logged

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well there are several approaches to this, firstly I/O expanders - chips that take a few pins to drive (such as I2C) and provide 8 or 16 I/O pins (but lower bandwidth than direct pins).

Secondly you can use a resistor network to convert several switch inputs into an analog voltage to be read by one analog pin.  The absolute limit is 10 switches as the A/D converter is 10 bits, but in practice 5 or 6 per analog input would be plenty if you want to avoid problems of noise, linearity and component tolerances.  This approach is appealing in that a few resistors are all that's needed.

Also a simple shift-register or input-multiplexer approach would work - two approaches to rolling your own input expander.
Logged

[ I won't respond to messages, use the forum please ]

Atlanta
Offline Offline
Sr. Member
****
Karma: 1
Posts: 254
Arduino still rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1284097145 the analog approach
http://www.arduino.cc/en/Tutorial/ShiftIn the shifty approach
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Another option, with a bit of an early learning curve, but the effort will repay you handsomely, is to use one of the Dallas Semiconductor 1-Wire chips. That would give you 8 inputs for the "price" of one Arduino I/O bit.

1-Wire is often used by Arduino forum folk for the temperature sensors in the product line, but there are many, many other devices which work the same way. The 8 bit I/O chip is the DS2408, dta sheet....

http://www.maxim-ic.com/datasheet/index.mvp/id/3818

I believe it can be configured to "catch" transient inputs, too... so you don't need to monitor the lines intensively.

More on 1-Wire generally at...

http://www.arunet.co.uk/tkboyd/e1didx.htm
« Last Edit: January 20, 2011, 03:07:45 am by tkbyd » Logged

Pages: [1]   Go Up
Jump to: