Hardware Reference
In-Depth Information
The joystick can register the exact x -axis and y -axis position, and also has a
center-push button.
To read the joystick inputs, use readJoystickX() and readJoystickY() .
xValue = Esplora.readJoystickX();
yValue = Esplora.readJoystickY();
These functions both return an int : Values range from -512 to 512. A return
value of zero means that the joystick is in the center and has not been moved.
Negative values mean that the joystick is pushed to the left ( x ) or down ( y ).
Positive values mean that the joystick is pushed to the right ( x ) or up ( y ).
To read the center-push button, you can use readJoystickSwitch() .
value = Esplora.readJoystickSwitch();
The return value is an int and is either 0 or 1,023. Remember that readJoy-
stickX() and readJoystickY() return 10-bit values and are shifted to make
things easier. The center button also returns a 10-bit value but because it is either
pushed or not, values returned are extremes. If you need something simpler to
use, you can use the readJoystickButton() function.
state = Esplora.readJoystickButton();
This function returns a Boolean : LOW if the button is pressed and HIGH if the
button is not pressed.
To read the status of the buttons, there is only one function: readButton() .
state = Esplora.readButton(button);
This function takes one parameter, the button that is to be read. The button
parameter can be one of four constants: SWITCH_DOWN , SWITCH_LEFT , SWITCH_UP ,
or SWITCH_RIGHT . This function returns one of two values: HIGH or LOW . A return
value of HIGH means the button is in the high position; that is to say, it has not
been pressed. A return value of LOW means that the button is in the low position
and is currently pressed.
Buzzer
The Arduino Esplora has a buzzer located on the top left of the device that can
create simple audio outputs. To create an audio output, use tone() .
Esplora.tone(frequency);
Esplora.tone(frequency, duration);
The frequency parameter specii es the audio frequency in hertz, expressed
as an unsigned int . The optional duration parameter is the duration of the
 
Search WWH ::




Custom Search