Support » Pololu AVR C/C++ Library User’s Guide » 3. Functional Overview and Example programs »
3.e. Orangutan LED Control Functions
Overview
These functions allow you to easily control the user LED(s) on the 3pi Robot, Orangutan SV, Orangutan SVP, Orangutan LV-168, and Baby Orangutan B. On the Orangutan SV-xx8 and LV-168, there are two user LEDs are on the top side of the PCB with the red LED on the bottom left and the green LED on the top right. On the 3pi, there are two user LEDs on the bottom side of the PCB with the red LED on the right (when looking at the bottom) and the green LED on the left. Additional LEDs included with the 3pi may be soldered in on the top side (in parallel with the surface-mount LEDs on the underside) for easier viewing. The Orangutan SVP has two user LEDs: a red LED on the bottom right and a green LED on the top left. The Baby Orangutan has a single red LED and no green LED.
Note that the red LED is on the same pin as the UART0 serial transmitter (PD1), so if you are using UART0 for serial transmission then the red LED commands will not work, and you will see the red LED blink briefly whenever data is transmitted on UART0. Note that the green LED is on the same pin as an LCD control pin; the green LED will blink briefly whenever data is sent to the LCD, but the two functions will otherwise not interfere with each other.
C++ users: See Section 5.d of Programming Orangutans and the 3pi Robot from the Arduino Environment for examples of this class in the Arduino environment, which is almost identical to C++.
Complete documentation of these functions can be found in Section 10 of the Pololu AVR Library Command Reference.
This library comes with an example program in libpololu-avr\examples
.
1. led1
A simple example that blinks LEDs.
#include <pololu/orangutan.h> /* * led1: for the 3pi robot, Orangutan LV 168, Orangutan SV-xx8, Orangutan SVP, * or Baby Orangutan B * * This program uses the OrangutanLEDs functions to control the red and green * LEDs on the 3pi robot or Orangutan. It will also work to control the red * LED on the Baby Orangutan B (which lacks a second, green LED). * * http://www.pololu.com/docs/0J20 * http://www.pololu.com * http://forum.pololu.com */ int main() { while(1) { red_led(1); // red LED on delay_ms(1000); // waits for a second red_led(0); // red LED off delay_ms(1000); // waits for a second green_led(1); // green LED on (will not work on the Baby Orangutan) delay_ms(500); // waits for 0.5 seconds green_led(0); // green LED off (will not work on the Baby Orangutan) delay_ms(500); // waits for 0.5 seconds } return 0; }