5.d. OrangutanLEDs - LED Control Library

Overview

This library allows you to easily control the LED(s) on the 3pi robot, Orangutan SV-xx8, 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 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.

You do not need to initialize your OrangutanLEDs object before use. All initialization is performed automatically when needed.

All of the methods in this class are static; you should never have more than one instance of an OrangutanLEDs object in your sketch.

OrangutanLEDs Methods

Complete documentation of this library’s methods can be found in Section 6 of the Pololu AVR Library Command Reference.

Usage Examples

This library comes with an example sketch that you can load by going to File > Examples > OrangutanLEDs.

1. OrangutanLEDExample

Alternately blinks the red and green LEDs on the Orangutan SV-xx8, Orangutan LV-168, or 3pi robot. If you run this program on the Baby Orangutan B, you will only see the red user LED blink, but you can connect an external LED to pin PD7 (Arduino pin 7) if you want to see the second LED blink. If you do this, don’t forget to include a current-limiting resistor!

#include <OrangutanLEDs.h>

/*
 * OrangutanLEDExample: for the 3pi robot, Orangutan LV 168, Orangutan SV-xx8,
 *   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). 
 */

OrangutanLEDs leds;

void setup()                    // run once, when the sketch starts
{
}

void loop()                     // run over and over again
{
  leds.red(HIGH);               // red LED on
  delay(1000);                  // waits for a second
  leds.red(LOW);                // red LED off
  delay(1000);                  // waits for a second
  leds.green(HIGH);             // green LED on (will not work on the Baby Orangutan)
  delay(500);                   // waits for 0.5 seconds
  leds.green(LOW);              // green LED off (will not work on the Baby Orangutan)
  delay(500);                   // waits for 0.5 seconds
}