User Manual
10. Orangutan Serial Port Communication
The OrangutanSerial class and the C functions in this section provide access to the serial port(s) on the Orangutan
controllers and 3pi robot., enabling two-way TTL-level communication with another microcontroller, a serial
device, or (through a USB-serial adapter or RS-232 level converter) a personal computer.
The Baby Orangutan, Orangutan SV, Orangutan LV, and 3pi robot are based on the ATmega48/168/328 line of
AVR processors, which have a single UART that communicates on pins PD0 (RXD) and PD1 (TXD). Since
there is only one UART on these devices, you must omit the port argument when using the commands below.
The Orangutan SVP and Orangutan X2 are based on the AVR ATmega324/644/1284 line of AVR processors,
which have two UARTs. Port UART0 uses pins PD0 (RXD0) and PD1 (TXD0). Port UART1 uses pins PD2
(RXD1) and PD3 (TXD1). The SVP and X2 also have a port called USB_COMM, which lets you connect your
Orangutan directly to a computer to send and receive bytes over USB. When using this port, you must call
serial_check() regularly because this port does not support interrupts. See the Orangutan SVP User’s Guide
for more information about using this port on the Orangutan SVP. Since there are multiple serial ports, you
must include the port argument when using the commands below, and it must be either UART0, UART1, or
USB_COMM.
When sending data on a UART, a UDRE interrupt vector is called by default after each byte is sent, allowing the
library to automatically start sending the next byte from the send buffer. When receiving data, an RX interrupt
vector is called by default after each byte is received, allowing the library to automatically store the byte in
the receive buffer. To use a polling method instead of interrupts, see the serial_set_mode() and serial_check()
functions below.
These functions are not available within the Arduino environment, which has its own serial functions.
For a higher level overview of this library and programs that show how this library can be used, please see
Section 3.h of the Pololu AVR C/C++ Library User’s Guide [https://www.pololu.com/docs/0J20].
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
10. Orangutan Serial Port Communication Page 39 of 65