Arduino Esplora Mouse

Introduction: Arduino Esplora Mouse

About: I'm still here

The Arduino Esplora is one of the newest Arduino Boards. It is shaped like a game controller, and has built in inputs and outputs. You can read more about it here. I won one on Adafruit's Ask an Engineer, and I decided to build a mouse

Step 1: Get the Code

For some reason Instructables wont let me upload the code today. So you can get it here. UPDATE: Link is updated
Here is how the code works:

Esplora.writeRGB(0, 0, 10);                  
int start = Esplora.readButton(SWITCH_3);    
while(start == HIGH) {                       
  start = Esplora.readButton(SWITCH_3);

The Esplora turns sets the light blue to signal it is ready to go. It then sets an infinite loop until the top button is pressed.

JoyX = Esplora.readJoystickX();
JoyY = Esplora.readJoystickY();
Esplora.writeRGB(10, 0, 0);

The Esplora then sets the drift on the X and Y axis on the Joystick and sets the led to red to signal that is done.

int xValue = Esplora.readJoystickX();
int yValue = Esplora.readJoystickY();       
xValue = xValue - JoyX;                     
yValue = yValue - JoyY;                     

The Esplora reads the joystick values and removes the drift.

int JoyButton = Esplora.readJoystickButton();
int button1 = Esplora.readButton(SWITCH_1);  
int button2 = Esplora.readButton(SWITCH_2);  
int button3 = Esplora.readButton(SWITCH_3);  
int button4 = Esplora.readButton(SWITCH_4);  
int slide = Esplora.readSlider();            

The Esplora then reads the buttons

int mousespeed = map(slide, 0, 1023, 10, 0);
int mouseX = map( xValue,-512, 512, mousespeed, -mousespeed); 
int mouseY = map( yValue,-512, 512, -mousespeed, mousespeed); 

The Esplora now maps out the max speed of the mouse, and maps out the value of the mouse movement

if(button3 == LOW){                       
    if(activate == 1) activate = 0;
    else activate = 1;

If the top button is pressed, the Esplora swaps the value of the variable

if(activate == 1){
If the previously set variable is equal to one, the Esplora runs the loop

Esplora.writeRGB(0 , 10, 0 );                

The light is set to green and the Mouse is run

if(JoyButton == LOW || button2 == LOW);
    else Mouse.release(MOUSE_LEFT);

if(button1 == LOW);               
else Mouse.release(MOUSE_MIDDLE);

if(button4 == LOW);  
else Mouse.release(MOUSE_RIGHT);

Mouse.move(mouseX, mouseY, 0);

The Esplora presses and releases the buttons and moves the mouse using the previously set variables

else {
    Esplora.writeRGB(255, 0, 0 ); 

If the mouse is disabled, the Mouse connection is closed, and the led is set to red.

Step 2: How to Use the Mouse

Using the mouse is simple. I uploaded some pictures I modified from the Arduino Guides to explain how to use the mouse. So when you plug in the mouse, the light will turn blue. This means that it is waiting to calibrate the joystick and get rid of any drift. don't move the joystick and press the top button once. The light will turn red or green depending on how long you hold the button. A red light means the mouse is disabled. To enable the mouse, press the top button, and the light will turn green. When the mouse is enabled, the Joystick moves the mouse, the slider controls the speed of the mouse, and the bottom buttons match up with the buttons on the mouse.

Epilog Challenge V

Participated in the
Epilog Challenge V

Pocket Sized Electronics

Participated in the
Pocket Sized Electronics

1 Person Made This Project!


  • Tinkercad to Fusion 360 Challenge

    Tinkercad to Fusion 360 Challenge
  • Frozen Treats Speed Challenge

    Frozen Treats Speed Challenge
  • Home and Garden Contest

    Home and Garden Contest



5 years ago

Hey just wanted to let you know that the github link isn't working. Any chance you could update it?


6 years ago on Introduction

I tried this and just got this list of errors:

EPQ_Mouse.ino: In function 'void loop()':

EPQ_Mouse:67: error: 'Mouse' only supported on the Arduino LeonardoEPQ_Mouse:69: error: 'MOUSE_LEFT' was not declared in this scope

EPQ_Mouse:70: error: 'MOUSE_LEFT' was not declared in this scope

EPQ_Mouse:73: error: 'MOUSE_MIDDLE' was not declared in this scope

EPQ_Mouse:74: error: 'MOUSE_MIDDLE' was not declared in this scope

EPQ_Mouse:76: error: 'MOUSE_RIGHT' was not declared in this scope

EPQ_Mouse:77: error: 'MOUSE_RIGHT' was not declared in this scope

EPQ_Mouse:84: error: 'Mouse' only supported on the Arduino Leonardo'Mouse' only supported on the Arduino Leonard


Reply 6 years ago

Did you add

#include <Esplora.h>

in the beginning of your code?


9 years ago

Very cool! Can you include the code as a whole?

andrea biffi
andrea biffi

9 years ago on Introduction

this is REALLY useful! thanks!
Is it connected through USB? Does it work alone in Windows, with Arduino program closed?
That new Arduino board is a great improvement for diy gadgets!


Reply 9 years ago on Introduction

Hi! Thanks for the comment, The Esplora is based off of the same chip as the Leonardo, so it has native USB. The Mouse library lets the Arduino board pretend to be a HID Mouse, so it should work with any modern computer with a USB port. You don't even need the Arduino IDE installed. To setup the Esplora on a Mac, see this page.