Arduino Function: Esplora.readButton

Description

This function 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.

Examples

#include <Esplora.h>

void setup(){}

void loop()
{
int button = Esplora.readButton(SWITCH_DOWN);

if(button == LOW)
{
Esplora.writeRed(255);
}
else {
Esplora.writeRed(0);
}
}


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc