Home Page | Language Reference (extended) | SD Reference | 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 ) ;
  }
}

See also


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.