Ever wished you could pause a video without scrambling for the keyboard? That's exactly what this project does. Wave your hand, and your video pauses. Push it closer, and the volume goes up. It's a simple but satisfying build using an Arduino and a couple of ultrasonic sensors β no fancy hardware, no expensive components.
There are two HC-SR04 ultrasonic sensors mounted side by side β one tracking your left hand, one tracking your right. The Arduino constantly measures how far away each hand is, figures out what gesture you're making, and fires off a label like "Play/Pause" or "Vup" over USB serial. A small Python script running on your computer picks that up and presses the right keyboard shortcut on your behalf.
[Left Hand] ββ [HC-SR04 #1]
β [Arduino Uno] β USB Serial β [Python Script] β Media Controls
[Right Hand] ββ [HC-SR04 #2]
]
It's a clean split: the Arduino handles the sensing, Python handles the computer side.
| Component | Quantity |
|---|---|
| Arduino Uno (or any compatible board) | 1 |
| HC-SR04 Ultrasonic Sensor | 2 |
| Breadboard | 1 |
| Jumper Wires | As needed |
| A computer with Python installed | 1 |
Nothing too exotic β you can probably grab all of this for under $15 if you don't already have it.
| Sensor | Arduino Pin |
|---|---|
| Sensor 1 β Trigger | Digital Pin 1 |
| Sensor 1 β Echo | Digital Pin 2 |
| Sensor 2 β Trigger | Digital Pin 3 |
| Sensor 2 β Echo | Digital Pin 4 |
Both sensors share the Arduino's 5V and GND rails on the breadboard.
Once it's running, here's how to actually use it:
| Gesture | What it does | How to do it |
|---|---|---|
| β Both hands at 25β50 cm | Play / Pause | Hold both hands out in front of both sensors at the same time |
| π Left hand at 10β20 cm, push closer | Volume Up | Lock your left hand at 10β20 cm, then nudge it in (under 15 cm) |
| π Left hand at 10β20 cm, pull back | Volume Down | Lock your left hand at 10β20 cm, then pull it back (past 20 cm) |
| π Right hand at 10β20 cm, push closer | Rewind | Lock your right hand at 10β20 cm, then nudge it in (under 15 cm) |
| π Right hand at 10β20 cm, pull back | Fast Forward | Lock your right hand at 10β20 cm, then pull it back (past 20 cm) |
| π Right hand very close (0β8 cm) | Next | Quickly swipe your right hand close to the sensor |
The "lock" gestures take a beat to activate β hold your hand steady for a moment first, and the Arduino will confirm it's locked before watching for your next move.
Open Gesture_Control_code.ino in the Arduino IDE, plug in your Arduino, pick the right Board and Port under the Tools menu, and hit Upload. That's the hardware side done.
pip install pyserial pyautoguiOpen Gesture_control.py and update the serial port to match what your Arduino is using:
# Windows
ArduinoSerial = serial.Serial('COM3', 9600)
# macOS / Linux
ArduinoSerial = serial.Serial('/dev/ttyUSB0', 9600)Not sure which port? Check Tools β Port in the Arduino IDE β it'll be listed there.
python Gesture_control.pyClick on your video player to make sure it's focused, and you're good to go. Start gesturing!
βββ Gesture_Control_code.ino # Arduino firmware β reads sensors and sends gesture labels over serial
βββ Gesture_control.py # Python script β listens on serial and triggers keyboard shortcuts
βββ README.md
d
Can't connect to the Arduino / port not found
Double-check that the COM port in Gesture_control.py matches what the Arduino IDE shows. It changes depending on which USB port you plug into.
Gestures aren't being detected
Make sure there's nothing between your hands and the sensors β even a cluttered desk can cause false readings. If you want to see what the sensors are actually measuring, uncomment the debug Serial.print lines in the .ino file and open the Serial Monitor.
Keyboard shortcuts aren't working Your video player needs to be the active window. The Python script sends keystrokes to whatever's in focus, so if another window is on top, the commands will go there instead..
| Library | What it's for | Install |
|---|---|---|
pyserial |
Talks to the Arduino over USB | pip install pyserial |
pyautogui |
Sends keyboard shortcuts to your computer | pip install pyautogui |
Open source β take it, tweak it, make it your own.