User Manual
Function Reference
C++ and Arduino methods are shown in red.
C functions are shown in green.
static void OrangutanAnalog::setMode(unsigned char mode)
void set_analog_mode(unsigned char mode)
Used to set the ADC for either 8-bit or 10-bit conversions. The mode argument should be the either
MODE_8_BIT or MODE_10_BIT. When the ADC is in 8-bit mode, conversion results will range from 0 to
255 for voltages ranging from 0 to 5 V. When the ADC is in 10-bit mode, conversion results will range from
0 to 1023 for voltages ranging from 0 to 5 V. The default mode setting is MODE_10_BIT.
Example:
// run the ADC in 10-bit conversion mode
OrangutanAnalog::setMode(MODE_10_BIT);
// run the ADC in 10-bit conversion mode
set_analog_mode(MODE_10_BIT);
static unsigned char OrangutanAnalog::getMode()
unsigned char get_analog_mode()
Returns the current ADC mode. The return value will be MODE_8_BIT (1) if the ADC is in 8-bit conversion
mode, otherwise it will be MODE_10_BIT (0). The default mode setting is MODE_10_BIT.
static unsigned int OrangutanAnalog::read(unsigned char channel)
unsigned int analog_read(unsigned char channel)
Performs a single analog-to-digital conversion on the specified analog input channel and returns the result. In
8-bit mode, the result will range from 0 to 255 for voltages from 0 to 5 V. In 10-bit mode, the result will range
from 0 to 1023 for voltages from 0 to 5 V. The channel argument should be a channel number or keyword from
the appropriate table above. This function will occupy program execution until the conversion is complete
(approximately 100 us). This function does not alter the I/O state of the analog pin that corresponds to the
specified ADC channel.
static unsigned int OrangutanAnalog::readMillivolts(unsigned char channel)
unsigned int analog_read_millivolts(unsigned char channel)
This function is just like analog_read() except the result is returned in millivolts. A return value of 5000
indicates a voltage 5 V. In most cases, this function is equivalent to to_millivolts(analog_read(channel)).
However, on the Orangutan SVP, the channels measured by the auxiliary processor are reported to the AVR in
millivolts, so calling analog_read_millivolts is more efficient for those channels.
static unsigned int OrangutanAnalog::readAverage(unsigned char channel , unsigned int numSamples)
unsigned int analog_read_average(unsigned char channel, unsigned int numSamples)
Performs numSamples analog-to-digital conversions on the specified analog input channel and returns the
average value of the readings. In 8-bit mode, the result will range from 0 to 255 for voltages from 0 to 5 . In
10-bit mode, the result will range from 0 to 1023 for voltages from 0 to 5 V. The channel argument should be
a channel number or keyword from the appropriate table above. This function will occupy program execution
until all of the requested conversions are complete (approximately 100 us per sample). This function does not
alter the I/O state of the analog pin that corresponds to the specified ADC channel. On the Orangutan SVP,
the channels measured by the auxiliary processor are averaged on the auxiliary processor, and the library does
not support further averaging. For those channels, this function is equivalent to analog_read.
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
2. Orangutan Analog-to-Digital Conversion Page 9 of 65