Joystick Mouse
Novel computer input device
Joystick Mouse
Novel computer input device
What I wanted to learn, and why it interested me: I wanted to learn this because I wanted to make a 3d mouse for my CAD work.
Final outcome: I was able to use a joystick to control and click with the cursor on the screen of my computer
Images of final creative/exploratory output
Left to right: a breadboard with inputs into an Arduino Micro Pro, where a Joystick is wired up to the pins.
Final Video
Process images from development towards creative/exploratory output
The Arduino Micro Pro automatically typed the right keystrokes to type a certain message. It is wired up to a button, where each button press would type out the message.
Each time the button was pressed, the Arduino would remember the total presses and type it with a message.
Process and reflection:
I learned how the Arduino Micro Pro specifically has some technology that allows it to type keystrokes or move a cursor. I found this very interesting since I assumed the Arduino Uno, being bigger, might have some keyboard and mouse capabilities too. It was interesting since when I first tested out the joystick to move the mouse, I found that the mouse would only move diagonally. While troubleshooting, I realized it was because the Arduino Micro Pro I was using was poorly soldered, most likely allowing a certain analog range to flow through it. But I now know what to look for when I receive a limited analog range. I did not find this super challenging; however, having this prerequisite understanding of how the library for the keyboard and mouse work is pretty useful, considering how I might move towards a direction for my Project 2 that would interact with my laptop.
Technical details
Electrical Schematic
/*
60-223 Intro to Physical Computing, fall 2025
Domain-specific Skill Building exercise: [Joystick Mouse]
[The Arduino reads the joystick’s X and Y analog inputs, calculates how far the user's movement moves according to the joystick potentiometers, and maps those values to cursor motion. Using the Mouse library, it sends movement commands to the computer, letting the joystick directly control the mouse’s direction and speed on screen.]
Pin mapping:
Arduino pin | role | details
------------------------------
A0 input joystick X
A1 input joystick Y
2 input joystick switch input
Released to the public domain by the author, January 2024
Robert Zacharias, rzachari@andrew.cmu.edu
Sourced from CHATGPT, October 6th, 2025
/*
#include <Mouse.h>
const int VRx = A0;
const int VRy = A1;
const int SW = 2;
int range = 15; // mouse sensitivity (increase for faster movement)
int responseDelay = 10; // delay between readings (ms)
int center = 512; // joystick center value
int deadzone = 20; // how much movement to ignore near center
void setup() {
pinMode(SW, INPUT_PULLUP); // button is active LOW
Mouse.begin();
}
void loop() {
int xReading = analogRead(VRx);
int yReading = analogRead(VRy);
bool pressed = (digitalRead(SW) == LOW);
// Convert analog to movement (-range to +range)
int xMove = map(xReading, 0, 1023, -range, range);
int yMove = map(yReading, 0, 1023, range, -range);
// Deadzone to avoid jitter
if (abs(xReading - center) < deadzone) xMove = 0;
if (abs(yReading - center) < deadzone) yMove = 0;
// Move cursor
Mouse.move(xMove, yMove, 0);
// Handle button click
if (pressed) {
if (!Mouse.isPressed(MOUSE_LEFT)) Mouse.press(MOUSE_LEFT);
} else {
if (Mouse.isPressed(MOUSE_LEFT)) Mouse.release(MOUSE_LEFT);
}
delay(responseDelay);
}