Examples > Esplora

Esplora Kart

This example demonstrates how to turn your Esplora into a customized computer game pad. It uses the analog joystick and the four switches as inputs to a video game. The Esplora will appear to the computer as a standard keyboard, the computer will see joystick movement and button presses as keystrokes.

The configuration choosen in this example is suitable for SuperTuxKart, an open-source racing game, available for Windows, OSX, and Linux. It can be downloaded from http://supertuxkart.sourceforge.net/ .

Hardware Required

  • Arduino Esplora


Only your Arduino Esplora is needed for this example. Connect the Esplora to your computer with a USB cable.

Esplora as SuperTuxKart game controller


The default keys to play with the SuperTuxKart game are:

Look backB

You need to map these keyboard keystrokes to the available inputs on your Esplora board. To handle the eight different buttons, you'll use arrays, ordered lists of variables with a fixed size. Each array has an index (counting from 0) to keep track of the position you're reading in the array, and each position can contain a number.

This code uses three different arrays: one for the buttons you'll read, a second to hold the current state of the buttons, and a third to hold the keystrokes associated with each button.

The Esplora has the ability to appear to a connected computer as a USB keyboard, so when you press the buttons and move the joystick, it's just like pressing keys on your keyboard.

The for() loop checks the state of all the buttons and the joystick. If the button's state has changed, then the corresponding keypress or release is sent to the computer. See the keyboard library reference for more information on using the Esplora as a keyboard or mouse.

SORRY, There is an error at our code repository, please inform to web@arduino.cc

See Also: