Arduino

Reference Language | Libraries | Comparison | Changes

Esplora

## readButton()

#### Description

Reads a button's state and returns if it is HIGH or LOW.

#### Syntax

Esplora.readButton(button)

#### Parameters

button: the associated button that you wanto read. Valid argument are:

SWITCH_1 or SWITCH_DOWN
SWITCH_2 or SWITCH_LEFT
SWITCH_3 or SWITCH_UP
SWITCH_4 or SWITCH_RIGHT
JOYSTICK_DOWN = JOYSTICK_BASE
JOYSTICK_LEFT = JOYSTICK_BASE+1
JOYSTICK_UP = JOYSTICK_BASE+2
JOYSTICK_RIGHT = JOYSTICK_BASE+3

#### Returns

LOW when pressed, HIGH when not pressed.

#### Example

#include <Esplora.h>
void setup(){}
void loop()
{
int button = Esplora.readButton(SWITCH_DOWN);
if(button == LOW)
{
Esplora.writeRed(255);
}
else {
Esplora.writeRed(0);
}
}
[Get Code]

#### See also

readJoystickSwitch() Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

### Share

### This link has expired.
Please re-subscribe to our Newsletters.

### Subscribe to our Newsletters

Email

Please enter a valid email to subscribe

Arduino Newsletter
Arduino Store Newsletter

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy

###### Newsletter

- ©2015 Arduino
- Copyright Notice
- Contact us
- Careers