Adding more analog input pins


I know that the orngutan has 2 analog pins. But I need some more. is there a way to convert some of the digital pins to analog pins?


Pins PC0 - PC5 can be used as either digital I/Os or analog inputs. ADC channels 0 - 7 connect to pins PC0 - PC5, ADC6, and ADC7, respectively.

- Ben

is there something I have to do to define them as analog, they will get analog input and know how to deal with it?

Just leave them set as inputs (default) and read values from them as you would read ADC6 or ADC7. Do you have working code reading inputs on those pins yet?

For example, if you’re using the Orangutan-Lib libraries, you can use the analog functions:

analog8(1);//Reads 8-bit analog value of PC1

There are similar analog functions built into the Pololu Arduino libraries.


Thanks, that will do… by the way, what is the difference between 10 bit conversion and 8 bit conversion?

It’s the resolution of the measurement, a 10-bit measurement has four times more possible values over the same range than an 8-bit. Sort of like measuring a distance with a tape measure with inches marked on it compared to measuring the same distance with a tape measure that only has feet marked on it.

The ATMega analog input pins always take 10-bit measurements, which means they divide up the range form 0V to 5V into 1024 (2^10) possible measured values. The 8-bit analog function returns only the top eight bits of this value, so it’s like dividing the same 0V to 5V range into 256 (2^8) possible values. Since you can represent 8-bit numbers with just one byte, this might be a little easier to work with, plus the lower bits are probably just noise anyway (you can get more accurate 10-bit readings by taking lots of them and averaging them together, but 8-bit readings are just fine and dandy for lots of purposes).