COVID-19 impact: We are still operating and shipping all orders! We are operating with a reduced staff, so for critical requirements, including fighting COVID-19, please contact us so we can identify priorities. Click here for more info.

3.g. Orangutan Pushbutton Interface Functions


This library allows you to easily interface with the three user pushbuttons on the 3pi robot, Orangutan SV, Orangutan SVP, and Orangutan LV-168 by either polling for the state of specific buttons or by waiting for press/release events on specifiable buttons. The first time any function in this section is called, the function will initialize all the button I/O pins to be inputs and enable their internal pull-up resistors. The wait_for_button_…() methods in this library automatically take care of button debouncing.

C++ users: See Section 5.f of Programming Orangutans 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 9 of the Pololu AVR Library Command Reference.

This library comes with an example program in libpololu-avr\examples.

1. pushbuttons1

Demonstrates interfacing with the user pushbuttons. It will wait for you to push either the top button or the bottom button, at which point it will display on the LCD which button was pressed. It will also detect when that button is subsequently released and display that to the LCD.

#include <pololu/orangutan.h>

 * OrangutanPushbuttonExample: for the Orangutan LV-168,
 *   Orangutan SV-xx8, Orangutan SVP, and 3pi robot
 * This example uses the OrangutanPushbuttons library to detect user
 * input from the pushbuttons, and it uses the OrangutanLCD library to
 * display feedback on the LCD.

int main()
    // wait for either the top or bottom buttons to be pressed
    // store the value of the pressed button in the variable 'button'
    unsigned char button = wait_for_button_press(TOP_BUTTON | BOTTOM_BUTTON);
    if (button == TOP_BUTTON)     // display the button that was pressed
      print("top down");
      print("bot down");
    wait_for_button_release(button);  // wait for that button to be released
    print("released");      // display that the button was released

Related Products

Encoder for Pololu Wheel 42x19mm
Pololu 42×19mm Wheel and Encoder Set
Orangutan SV-168 Robot Controller
Orangutan SVP-1284 Robot Controller (assembled)
Orangutan SVP-1284 Robot Controller (partial kit)
QTR-1RC Reflectance Sensor (2-Pack)
QTR-L-1A Reflectance Sensor (2-Pack)
QTR-L-1RC Reflectance Sensor (2-Pack)
QTR-3A Reflectance Sensor Array
QTR-3RC Reflectance Sensor Array
QTR-1RC Reflectance Sensor
QTR-1A Reflectance Sensor
QTR-1A Reflectance Sensor (2-Pack)
Orangutan SVP-324 Robot Controller (partial kit)
Orangutan SV-328 + USB Programmer Combo
Baby Orangutan B-328 Robot Controller
Orangutan SV-328 Robot Controller
Baby Orangutan B-328 + USB Programmer Combo
Baby Orangutan B-48 Robot Controller
QTR-8A Reflectance Sensor Array
QTR-8RC Reflectance Sensor Array
Pololu 3pi Robot
Baby Orangutan B-168 + USB Programmer Combo
Baby Orangutan B-48 + USB Programmer Combo
Orangutan LV-168 + USB Programmer Combo
Orangutan LV-168 Robot Controller
Orangutan SV-168 + USB Programmer Combo
Orangutan SVP-324 Robot Controller (assembled)
Orangutan LV-168 + USB Programmer Combo
Orangutan SV-328 + USB Programmer Combo
3pi Robot + USB Programmer + Cable Combo
Baby Orangutan B-48 + USB Programmer Combo
Baby Orangutan B-328 + USB AVR Programmer Combo
Orangutan X2 with VNH3
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors