Since the quarantine (covid-19) I decided to create something so I decided on mouse moved by rotation of my hand.
video:
Project Perspective
The Gyro-mouse project is an advanced Human Interface Device (HID) that allows you to control a computer's mouse cursor by physically tilting or moving the Arduino. This project is perfect for accessibility, VR controllers, or innovative gaming peripherals.
Hardware Core
- Arduino Leonardo / Micro: These boards are essential because they feature the ATmega32U4 microcontroller, which has native USB communication built-in. This allows the computer to recognize the Arduino as a standard HID Mouse.
- MPU6050 Sensor: A 6-axis Motion Tracking device that contains a 3-axis gyroscope and a 3-axis accelerometer. It detects even the slightest tilt or rotation.
Theory of Operation
The MPU6050 communicates with the Arduino over the I2C protocol (using Pin 2/SDA and Pin 3/SCL on the Leonardo). The Arduino then continuously reads the raw gyro data (X and Y axes).
- Motion to Pixels: The Arduino "maps" the angular velocity (rotation) from the gyroscope into pixels on the screen.
- Smoothing: Since raw gyro data can be noisy, the code often implements a simple filter or threshold to prevent the cursor from "drifting" when the mouse is still.
- Transmission: Using the
Mouselibrary, the Arduino sends motion packets to the PC:
Mouse.move(x_val, y_val, 0);
Essential Wiring
- VCC/GND: Connect to 5V and Ground.
- SCL/SDA: Connect to the dedicated SCL and SDA pins on your Arduino (I2C).
- INT: Optional, often used for hardware-level interrupts when data is ready.
Future Expansion
- Buttons: Add physical push buttons to the Arduino to act as left and right mouse clicks.
- Z-Axis Scroll: Use the Z-axis of the gyro to control the scroll wheel.
- Wireless Unity: Use a Bluetooth module to send the HID data wirelessly for a truly cable-free mouse experience.
Building your own Gyro-mouse is an excellent way to understand HID communication and multi-axis sensor fusion.