Wearable Finger Air Mouse with Raspberry Pi Pico
Slip it on your finger, point at the screen and the cursor follows! A tiny gyroscope rides on your fingertip, and your thumb taps the buttons to click. It’s a ring mouse you build yourself.
- Level: Intermediate
- Time: about 2 hours
- Ages 11+ (with an adult helper)
What are we building?
A gyroscope feels how fast it turns. If we strap one to your index finger, then every time you point left, right, up or down, the Raspberry Pi Pico knows. It tells your computer to move the cursor the same way. Three little buttons give you left click, right click and a “hold to move” switch.
The gyroscope is the only part on your finger, because it is tiny and light. The Pico lives on a comfy band on the back of your hand or wrist, and a thin, bendy wire joins them.
What you need
| Part | How many |
|---|---|
| Raspberry Pi Pico (with header pins) | 1 |
| MPU6050 module (GY-521), the smaller the better | 1 |
| Small tactile push buttons (6 mm) | 3 |
| Thin, flexible silicone wire (4 colours) | about 1 m |
| Elastic or Velcro strip, about 1.5 cm wide | 2 pieces |
| Thin foam sheet or soft felt, double-sided tape | 1 small piece |
| Spiral wrap or tape to bundle the wires | 1 |
| Micro USB cable (with data wires) | 1 |
How it works
- Read: the Pico asks the gyroscope how fast your finger is turning.
- Smooth: a smoothing filter takes out small hand wobbles, which matters a lot on a moving finger.
- Hold to move: the cursor only moves while your thumb holds the “move” button. Let go and you can wave your hand around without the cursor going wild. This is called a clutch.
- Click: the left and right buttons act like mouse buttons.
Circuit diagram
Pin table
| Pico pin | Pin number | Connects to |
|---|---|---|
| 3V3(OUT) | 36 | MPU6050 VCC |
| GND | 38 | MPU6050 GND |
| GP4 (SDA) | 6 | MPU6050 SDA |
| GP5 (SCL) | 7 | MPU6050 SCL |
| GP14 | 19 | Left-click button |
| GP15 | 20 | Right-click button |
| GP13 | 17 | Hold-to-move button |
| GND | 18 or 23 | Other leg of all three buttons |
3V3(OUT). No resistors are needed for the buttons because the code turns on the Pico’s built-in pull-ups. The four sensor wires and the shared button ground are what run along your hand.Step-by-step instructions
Test on a breadboard first
Set up the Pico with CircuitPython and the
adafruit_hidlibrary: hold BOOTSEL while plugging in, drag the Pico.uf2from circuitpython.org onto the RPI-RP2 drive, then copy theadafruit_hidfolder from the Adafruit library bundle intolibon the CIRCUITPY drive. Wire the circuit on a breadboard and save the code below ascode.py. Check that it works before you build the wearable.Make the finger band
Cut a strip of elastic or Velcro that wraps around the middle part of your index finger. Stick a small piece of foam on top as a soft pad. Attach the MPU6050 on the foam with double-sided tape. Keep the board flat on top of the finger, with its printed Y arrow pointing toward your fingertip.
Add the buttons
Stick the three small buttons on a thin strip along the side of your index finger, where your thumb naturally rests. Join one leg of each button to a shared ground wire. Solder a signal wire to each other leg: left click, right click and hold-to-move.
Make the wrist band
Fix the Pico to a wide elastic band or wrist strap using Velcro or tape, with the USB port pointing toward your elbow. Solder or plug in the wires as in the pin table. Bundle the wires with spiral wrap, leaving a little slack so the finger can bend freely. Tape the wire to the back of the hand so it does not tug on the solder joints.
Calibrate and play
Rest your hand on the table and plug in the USB. Keep your hand still for 3 seconds while it learns its resting numbers. Then point your finger, press and hold the “move” button with your thumb, and steer! If the cursor goes the wrong way, change
INVERT_XorINVERT_Y.
CircuitPython code
Save this as code.py on the CIRCUITPY drive.
import time
import struct
import board
import busio
import digitalio
import usb_hid
from adafruit_hid.mouse import Mouse
# ---- Settings you can change ----
INVERT_X = 1 # use -1 to flip left/right
INVERT_Y = 1 # use -1 to flip up/down
SPEED_DIVIDER = 500 # bigger = slower cursor
DEAD_ZONE = 120 # ignore tiny shakes
SMOOTHING = 0.6 # 0 = none, 0.9 = very smooth
REQUIRE_HOLD = True # move only while the "move" button is held
MPU = 0x68
mouse = Mouse(usb_hid.devices)
i2c = busio.I2C(scl=board.GP5, sda=board.GP4, frequency=400000)
while not i2c.try_lock():
pass
i2c.writeto(MPU, bytes([0x6B, 0x00])) # wake the sensor up
def make_button(pin):
b = digitalio.DigitalInOut(pin)
b.switch_to_input(pull=digitalio.Pull.UP)
return b
left_btn = make_button(board.GP14)
right_btn = make_button(board.GP15)
move_btn = make_button(board.GP13)
def read_gyro():
buf = bytearray(6)
i2c.writeto_then_readfrom(MPU, bytes([0x43]), buf)
gx, gy, gz = struct.unpack(">hhh", buf)
return gx, gz
def clamp(v):
return max(-127, min(127, int(v)))
# ---- Calibration: keep your hand still! ----
time.sleep(3)
sum_x = sum_z = 0
for _ in range(200):
gx, gz = read_gyro()
sum_x += gx
sum_z += gz
time.sleep(0.005)
offset_x = sum_x / 200
offset_z = sum_z / 200
smooth_x = smooth_z = 0.0
active = True
left_down = right_down = False
while True:
# Press left + right together to pause or resume
if not left_btn.value and not right_btn.value:
active = not active
mouse.release_all()
left_down = right_down = False
while not left_btn.value or not right_btn.value:
time.sleep(0.05)
continue
gx, gz = read_gyro()
gx -= offset_x
gz -= offset_z
smooth_x = smooth_x * SMOOTHING + gx * (1 - SMOOTHING)
smooth_z = smooth_z * SMOOTHING + gz * (1 - SMOOTHING)
if active:
can_move = (not REQUIRE_HOLD) or (not move_btn.value)
if can_move:
move_x = move_y = 0
if abs(smooth_z) > DEAD_ZONE:
move_x = INVERT_X * (-smooth_z) / SPEED_DIVIDER
if abs(smooth_x) > DEAD_ZONE:
move_y = INVERT_Y * (-smooth_x) / SPEED_DIVIDER
if move_x or move_y:
mouse.move(clamp(move_x), clamp(move_y))
if not left_btn.value and not left_down:
mouse.press(Mouse.LEFT_BUTTON)
left_down = True
if left_btn.value and left_down:
mouse.release(Mouse.LEFT_BUTTON)
left_down = False
if not right_btn.value and not right_down:
mouse.press(Mouse.RIGHT_BUTTON)
right_down = True
if right_btn.value and right_down:
mouse.release(Mouse.RIGHT_BUTTON)
right_down = False
time.sleep(0.01)
REQUIRE_HOLD = True the cursor stays still until you hold the move button, which makes the first test much safer.Tips and troubleshooting
The cursor is jumpy
Raise SMOOTHING to 0.7 or 0.8, or raise DEAD_ZONE. Make sure the sensor is stuck down firmly and does not wobble on the foam.
The cursor is too fast or slow
Change SPEED_DIVIDER. Smaller is faster and bigger is slower.
Left and right (or up and down) are wrong
Change INVERT_X or INVERT_Y to -1. If the two are swapped, swap gx and gz in the code. This depends on how the sensor sits on your finger.
It stops working when I bend my finger
A wire joint may be loose or pulled. Add slack in the wire, tape it down, and re-solder any weak joints.
I get a “No I2C device” message
Check SDA (GP4) and SCL (GP5), and make sure the sensor is powered from 3V3.
What did we learn?
- Wearable technology puts electronics on your body, so it must be light, soft and safe.
- Gyroscopes measure how fast something turns.
- Filtering smooths out noisy sensor data.
- A clutch button is a design trick that stops accidental movement.
Try these challenges
- Make a case for the sensor with a 3D printer or card.
- Use a Raspberry Pi Pico W or ESP32 with a small battery to go wireless, with an adult’s help.
- Add a flick gesture to switch slides in a presentation.
- Control a game or a robot arm with your finger.
Questions kids ask
Why is the Pico on my wrist and not my finger?
The Pico is long and heavier than a finger band should carry. Only the tiny sensor goes on the fingertip.
Can I make it truly ring-sized?
Yes, with a very small sensor board and a tiny microcontroller plus a small battery. That is a bigger challenge, so ask an adult to help.
Does it work with phones and tablets?
Many Android devices accept a USB mouse with an adapter. Check your device first.
Comments
Post a Comment