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.
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.
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....
I believe it can be configured to "catch" transient inputs, too... so you don't need to monitor the lines intensively.