Support » Pololu AVR Library Command Reference »
6. Orangutan LEDs
<p>The OrangutanLEDs class and the C functions in this section are a very simple interface to the user LEDs included on Orangutan controllers and 3pi. The Orangutan X2 has five user LEDs (two red, two green, and one yellow), the Orangutan LV, SV, SVP, and 3pi have two user LEDs (one red and one green), and the Baby Orangutan has one user LED (red).</p>
<p>On all devices except the Orangutan X2, 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 functions will not work, and you will see the red LED blink briefly whenever data is transmitted on UART0.</p>
<p>On all devices except the Baby Orangutan, the green LED is on the same pin as an LCD data pin, and the green LED will blink briefly whenever data is sent to the LCD, but the two functions will otherwise not interfere with each other. On the Orangutan X2, all the user LEDs are LCD data pins, so they will briefly flash whenever data is sent to the LCD, and the LCD can sometimes drive these LEDs if the AVR pins they are on are configured as inputs (their default configuration). To stop the LCD from keeping the LEDs lit, you can use the functions in this library to explicitly turn them off at the start of your program, which will make the AVR pins driving-low outputs.</p>
<p>For a higher level overview of this library and example programs that show how this library can be used, please see <strong><a href="/docs/0J20/3.e">Section 3.e</a></strong> of the <a href="/docs/0J20">Pololu AVR C/C++ Library User’s Guide</a>.</p>
<div class="libpololu">
<h2>Reference</h2>
<div class="key">
<p class="cpp"><strong>C++ and Arduino methods are shown in red.</strong></p>
<p class="c"><strong>C functions are shown in green.</strong></p>
</div>
<p class="cpp">static void OrangutanLEDs::<strong>red</strong>(unsigned char <em>state</em>)</p>
<p class="c">void <strong>red_led</strong>(unsigned char <em>state</em>)</p>
<p class="def">This method will turn the red user LED off if <em>state</em> is zero, it will toggle the LED state if <em>state</em> is 255, else it will turn the red user LED on. You can use the keyword <strong>HIGH</strong> as an argument to turn the LED on, and you can use the keyword <strong>LOW</strong> as an argument to turn the LED off. You can use the keyword <strong>TOGGLE</strong> to toggle the LED state.</p>
<h3>Example:</h3>
<pre name="code" class="c">
red_led(HIGH);
// in C++: OrangutanLEDs::red(HIGH); // turn the red LED on</pre>
<p class="cpp">static void OrangutanLEDs::<strong>green</strong>(unsigned char <em>state</em>)</p>
<p class="c">void <strong>green_led</strong>(unsigned char <em>state</em>)</p>
<p class="def">This method will turn the green user LED off if <em>state</em> is zero, it will toggle the LED state if <em>state</em> is 255, else it will turn the green user LED on. You can use the keyword <strong>HIGH</strong> as an argument to turn the LED on, and you can use the keyword <strong>LOW</strong> as an argument to turn the LED off. You can use the keyword <strong>TOGGLE</strong> to toggle the LED state. The Baby Orangutan does not have a green user LED, so this function will just affect the output state of user I/O pin PD7.</p>
<h3>Example:</h3>
<pre name="code" class="c">
green_led(LOW);
// in C++: OrangutanLEDs::green(LOW); // turn the green LED off</pre>
<p class="cpp">static void OrangutanLEDs::<strong>left</strong>(unsigned char <em>state</em>)</p>
<p class="c">void <strong>left_led</strong>(unsigned char <em>state</em>)</p>
<p class="def">For the Orangutan LV, SV, X2, Baby Orangutan, and the 3pi, this method is an alternate version of red(). The red LED is on the left side of most of these boards. For the Orangutan SVP, this method is an alternate version of green().</p>
<p class="cpp">static void OrangutanLEDs::<strong>right</strong>(unsigned char <em>state</em>)</p>
<p class="c">void <strong>right_led</strong>(unsigned char <em>state</em>)</p>
<p class="def">For the Orangutan LV, SV, X2, Baby Orangutan, and the 3pi, this method is an alternate version of green(). The green LED is on the right side of most of these boards. For the Orangutan SVP, this method is an alternate version of red().</p>
<p class="cpp">static void OrangutanLEDs::<strong>red2</strong>(unsigned char <em>state</em>)</p>
<p class="c">void <strong>red_led2</strong>(unsigned char <em>state</em>)</p>
<p class="def">This method controls the Orangutan X2’s second red user LED and <ins>is only defined for the Orangutan X2 version of the library</ins>. You can use the keyword <strong>HIGH</strong> as an argument to turn the LED on, and you can use the keyword <strong>LOW</strong> as an argument to turn the LED off. You can use the keyword <strong>TOGGLE</strong> to toggle the LED state.</p>
<p class="cpp">static void OrangutanLEDs::<strong>green2</strong>(unsigned char <em>state</em>)</p>
<p class="c">void <strong>green_led2</strong>(unsigned char <em>state</em>)</p>
<p class="def">This method controls the Orangutan X2’s second green user LED and <ins>is only defined for the Orangutan X2 version of the library</ins>. You can use the keyword <strong>HIGH</strong> as an argument to turn the LED on, and you can use the keyword <strong>LOW</strong> as an argument to turn the LED off. You can use the keyword <strong>TOGGLE</strong> to toggle the LED state.</p>
<p class="cpp">static void OrangutanLEDs::<strong>yellow</strong>(unsigned char <em>state</em>)</p>
<p class="c">void <strong>yellow_led</strong>(unsigned char <em>state</em>)</p>
<p class="def">This method controls the Orangutan X2’s yellow user LED and <ins>is only defined for the Orangutan X2 version of the library</ins>. You can use the keyword <strong>HIGH</strong> as an argument to turn the LED on, and you can use the keyword <strong>LOW</strong> as an argument to turn the LED off. You can use the keyword <strong>TOGGLE</strong> to toggle the LED state.</p>
</div>