AVR Library Command Reference

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 library defines the keywords MODE_8_BIT and
MODE_10_BIT, which can be used as the argument to this method. When the ADC is in 8-bit mode, conversion
results will range from 0 255 for voltages ranging from 0 5 V. When the ADC is in 10-bit mode, conversion
results will range from 0 – 1023 for voltages ranging from 0 – 5 V. The default mode setting is MODE_10_BIT.
Example:
// run the ADC in 10-bit conversion mode
OrangutanAnalog::setMode(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 255 for voltages from 0 5 . In 10-bit mode, the result will range from
0 1023 for voltages from 0 5 V. The channel argument should be 0 7. This function will occupy program
execution until the conversion is complete (approximately 100 us). Pull-up resistors are automatically disabled
during the conversion, then restored to their previous state.
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 255 for voltages from 0 5 . In 10-bit mode,
the result will range from 0 1023 for voltages from 0 5 V. The channel argument should be 0 7. This
function will occupy program execution until all of the requested conversions are complete (approximately 100 us
per sample). Pull-up resistors are automatically disabled during the conversion, then restored to their previous
state.
static unsigned int OrangutanAnalog::readTrimpot()
unsigned int read_trimpot()
Performs 20 analog-to-digital conversions on the output of the trimmer potentiometer on the 3pi, Orangutan
SV-168, Orangutan LV-168, or Baby Orangutan B and returns the average result. In 8-bit mode, the result will
range from 0 255 for voltages from 0 5 . In 10-bit mode, the result will range from 0 1023 for voltages from
0 – 5 V. The trimpot is on analog input 7, so this method is equivalent to readAverage(TRIMPOT, 20).
static int OrangutanAnalog::readTemperatureF()
int read_temperature_f()
Performs 20 analog-to-digital conversions on the output of the temperature sensor on the Orangutan LV-168 and
returns average result in tenths of a degree Farenheit, so a result of 827 would mean a temperature of 82.7 degrees
F. The temperature sensor is on analog input 6, so this method is equivalent to readAverage(TEMP_SENSOR, 20)
converted to tenths of a degree F.
static int readTemperatureC()
Pololu AVR Library Command Reference © 2001–2009 Pololu Corporation
3. Orangutan Analog-to-Digital Conversion Page 6 of 35