I’m actually doing something similar to this. I had to adapt some of my code, but here is everything but the mouse movement because that is quite complicated.
I’m pretty sure this code will work:
int right = Esplora.readButton(SWITCH_RIGHT);
int left = Esplora.readButton(SWITCH_LEFT);
int down = Esplora.readButton(SWITCH_DOWN);
int up = Esplora.readButton(SWITCH_UP);
int mic = Esplora.readMicrophone();
int lshift = Esplora.readJoystickButton();
int leftright = Esplora.readJoystickX();
int updown = Esplora.readJoystickY();
//these are the values for the accelerometer.
int xAxis = Esplora.readAccelerometer(X_AXIS); // read the X axis
int yAxis = Esplora.readAccelerometer(Y_AXIS); // read the Y axis
int zAxis = Esplora.readAccelerometer(Z_AXIS); // read the Z axis
if(up == LOW)
if(down == LOW)
if(left == LOW)
if(right == LOW)
Mouse.click(MOUSE_RIGHT); //this will press and release once. You will need to recode to be able to hold it down.
if (mic > 350) //edit 350 for the amplitude of the sound. (higher number means it will be triggered by a louder sound)
if (lshift == LOW)
// this will simply press and release. if you wish to have it be held down, add a delimiter here.
if (updown > 450)
if (updown < -450)
if (leftright < -450)
if (leftright > 450)
delay(1); //amount of time delay per loop, measured in milliseconds.
A problem you will run into is how long you want to have something pressed down. This code loops over and over every millisecond and presses and releases a button when it is down. For example, if the left shift key is used as a crouch, even if the user holds the joystick down, the shift will be pressed and released every time, and you will end up with a high-speed teabag. To fix this, add a delimiter to indicate when to release the key, such as:
int pause = Esplora.readButton(SWITCH_RIGHT);
if(pause == LOW)
Keyboard.press(KEY_ESC); //will be held until the button is released.
if(pause == HIGH)
I am kind of scared of the mouse control thing, but the variables for the accelerometer are included in the code. I am a bit of a noob too, but if you have questions I can try and answer them.
This might help with mouse movement: http://forum.arduino.cc/index.php?topic=139102.0