5.d. OrangutanLEDs - LED Control Library

Overview

This library allows you to easily control the LED(s) on the3pi robot, Orangutan LV-168, or Baby Orangutan B. The 3pi and Orangutan LV-168 have two user LEDs: a red LED on the bottom left and a green LED on the top right. On the Orangutan LV-168, the 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, the LEDs are 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. There are through-holes on the 3pi PCB that allow you to solder your own parallel LEDs to the top side of the board. Note that the green LED on both the 3pi and the Orangutan LV-168 is on a line shared by the LCD, so it will often faintly flicker whenever your program updates the LCD. The Baby Orangutan B has a single, red user LED.

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 > Sketchbook > Examples > Library-OrangutanLEDs.

1. OrangutanLEDExample

Alternately blinks the red and green LEDs on the 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.

#include <OrangutanLEDs.h>

/*
 * OrangutanLEDExample for the 3pi robot, Orangutan LV-168, or Baby Orangutan B
 *
 * This sketch uses the OrangutanLEDs library to control the red and green
 * LEDs on the Orangutan LV-168 or 3pi.  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

  // the following segment will not work on the Baby Orangutan
  leds.green(HIGH);             // green LED on
  delay(500);                   // waits for 0.5 seconds
  leds.green(LOW);              // green LED off
  delay(500);                   // waits for 0.5 seconds
}