I Turned My Hands Into a Virtual Steering Wheel!!
by Dynamic Innovator in Circuits > Software
7 Views, 0 Favorites, 0 Comments
I Turned My Hands Into a Virtual Steering Wheel!!

What Is This Project?
Imagine you're playing a car racing game… but instead of using a joystick or keyboard, you just move your hands in front of a camera to drive the car! This project makes that possible using a webcam, Python.
You can:
- 👐 Turn your hands left or right to steer the car.
- 👍 Move your thumb down to speed up or slow down. It’s like magic! But it’s actually made using something called Computer Vision.
This project is designed for complete beginners and fun enthusiasts who want to control a car using hand gestures with a webcam. The program uses MediaPipe to track your hand, calculates the angle between your wrist, thumb, and index finger, and based on that angle, it sends keyboard commands to the game.
No fancy equipment needed—just a webcam, your hand, and a game that uses the keyboard (like pressing A/D to steer).
Let’s dive into how it works in the simplest way possible.
Supplies
Here’s everything you need:
- ️ A laptop or desktop computer (Windows, macOS, or Linux)
- A webcam (built-in or USB)
- Python installed (version 3.7 or later)
- Python packages:
- opencv-python
- mediapipe
- pyautogui
Install Python
.jpg)
If you haven’t already:
- Go to https://www.python.org/
- Click Download Python
- Install it like any other app
Install the Libraries



These are the special helpers for Python:
- Open Command Prompt (Windows) or Terminal (Mac/Linux)
- Type the following and press Enter:
What Are These Libraries?
Let’s understand them like superheroes:
- 🧠 Mediapipe – This smart tool sees your hands and finds points like your thumb, wrist, and fingers.
- 👀 OpenCV – It helps us use the webcam and draw things on the screen.
- ⌨️ PyAutoGUI – It presses keys like W, A, S, D for you.
Copy the Code
this took me days to figuring out and i am giving you the code for free!!!
Here’s the magic program. You can open Notepad, or better: install VS Code.
Downloads
Explaination of Code and Important Settings in Code Before Using It
🔍 Explaining the Key Code Lines
✅ Importing Tools
✅ Initial Settings
- This initializes MediaPipe Hands to detect up to 2 hands.
- It finds where your hands are and tracks their movement.
✅ Detecting Angle Between Hands
- Calculates the angle between your left and right hands.
- This tells whether you're turning left, right, or going straight.
🧠 Important Settings :
🛠 turn_sensitivity = 0.01
- This was used in a previous version to make turning more or less sensitive.
- BUT in your current code, it's not used anymore, so we can remove it or ignore it.
🔁 straight_threshold = 6
This value decides how much your hand angle must change before it counts as turning.
- If the angle is less than -6, it means turn left (A key).
- If the angle is more than +6, it means turn right (D key).
- If the angle is between -6 and +6, it means go straight (do nothing).
This helps avoid small hand shakes being treated as turns.
⏱️ tap_duration = 0.01
This sets how quickly to release the A or D key after tapping it.
- 0.01 means the key is held down for just 0.01 seconds (very short).
- This makes the car turn in small steps, so you don’t turn too much with a small hand movement.
If you want smoother, longer turns, increase this value to something like 0.05.
🖐️ Detecting Thumb Up or Down
- Checks if the tip of the thumb is above the second joint (on the screen).
- This is used to detect:
- Left thumb up = stop accelerating
- Right thumb up = stop braking
🚗 Controls Using Hands
🟢 Accelerate (W key)
- If your left thumb is down, press the W key (accelerate).
- If your left thumb goes up, release the W key (stop).
🔴 Brake (S key)
- If your right thumb is down, press the S key (brake).
- If your right thumb goes up, release the S key (stop braking).
↔️ Turn Left or Right (A and D keys)
- Angle < -6: Press A (turn left)
- Angle > +6: Press D (turn right)
These are short taps, so the car turns briefly and doesn't stay turning forever.
🧹 At the End
- When you exit the program, it releases all keys to avoid the car getting stuck going forward or turning.
✅ Final Thoughts
🎮 What You Can Control
Important Settings in Code Before Using It
🧠 Important Settings :
🛠 turn_sensitivity = 0.01
- This was used in a previous version to make turning more or less sensitive.
- BUT in your current code, it's not used anymore, so we can remove it or ignore it.
🔁 straight_threshold = 6
This value decides how much your hand angle must change before it counts as turning.
- If the angle is less than -6, it means turn left (A key).
- If the angle is more than +6, it means turn right (D key).
- If the angle is between -6 and +6, it means go straight (do nothing).
This helps avoid small hand shakes being treated as turns.
⏱️ tap_duration = 0.01
This sets how quickly to release the A or D key after tapping it.
- 0.01 means the key is held down for just 0.01 seconds (very short).
- This makes the car turn in small steps, so you don’t turn too much with a small hand movement.
If you want smoother, longer turns, increase this value to something like 0.05.