AVR Library Command Reference
Table Of Contents
- Pololu AVR Library Command Reference
- 1. Introduction
- 2. Timing and Delays
- Reference
- 3. Orangutan Analog-to-Digital Conversion
- Reference
- 4. Orangutan Buzzer: Beeps and Music
- Reference
- 5. Orangutan LCD
- Reference
- 6. Orangutan LEDs
- Reference
- 7. Orangutan Motor Control
- Reference
- 8. Orangutan Pushbuttons
- Reference
- 9. Orangutan Serial Port Communication
- Reference
- 10. Orangutan System Resources
- 11. QTR Reflectance Sensors
- Reference
- 12. 3pi Robot Functions
- 13. Wheel Encoders
- Reference
int read_temperature_c()
This method is the same as readTemperatureF() above, except that it returns the temperature in tenths of a degree
Celcius.
static int readBatteryMillivolts_3pi()
int read_battery_millivolts_3pi()
Performs 10 analog-to-digital conversions on the battery voltage sensing circuit of the 3pi and returns the average
result in millivolts. A result of 5234 would mean a battery voltage of 5.234 V. For rechargeable NiMH batteries,
the voltage usually starts at a value above 5 V and drops to around 4 V before the robot shuts off, so monitoring
this number can be helpful in determining when to recharge batteries.
static int readBatteryMillivolts_SV168()
int read_battery_millivolts_sv168()
Just like read_battery_millivolts_3pi() above, but uses the correct voltage factor for the Orangutan SV-168. The
minimum operating voltage for the SV-168 is 6 V, but if the batteries drop significantly below their rated value,
whatever it is, they should be recharged. For example, a six-cell NiMH pack should be recharged if it drops below
about 7 V.
static void OrangutanAnalog::startConversion(unsigned char channel)
void start_analog_conversion(unsigned char channel)
Initiates an ADC conversion that runs in the background, allowing the CPU to perform other tasks while the
conversion is in progress. The procedure is to start a conversion on an analog input with this method, then poll
isConverting() in your main loop. Once isConverting() returns a zero, the result can be obtained through a call to
conversionResult() and this method can be used to start a new conversion.
static unsigned char OrangutanAnalog::isConverting()
unsigned char analog_is_converting()
Returns a 1 if the ADC is in the middle of performing a conversion, otherwise it returns a 0. The ATmega168 is
only capable of performing one analog-to-digital conversion at a time.
static unsigned int conversionResult()
unsigned int analog_conversion_result()
Returns the result of the previous analog-to-digital conversion. 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.
static unsigned int toMillivolts(unsigned int adcResult)
static unsigned int to_millivolts(unsigned int adc_result)
Converts the result of an analog-to-digital conversion to millivolts. This assumes a board power level of exactly
5000 mV.
Example:
OrangutanAnalog::toMillivolts(OrangutanAnalog::read(0));
// e.g. will return 5000 if analog input 0 is at 5 V
Pololu AVR Library Command Reference © 2001–2009 Pololu Corporation
3. Orangutan Analog-to-Digital Conversion Page 7 of 35










