
The Gesture-Based LED Control System is a computer vision project that combines Python, MediaPipe, OpenCV, and Arduino to create a touchless LED control interface. A webcam tracks the user's index finger and allows interaction with a virtual slider displayed on the screen.
As the finger moves across the slider, corresponding LEDs connected to the Arduino are activated in real time through serial communication.
This project demonstrates:
220Ω ResistorsOpen a terminal and execute:
pip install opencv-python
pip install mediapipe
pip install pyserial
Confirm that all required libraries are installed successfully before running the Python application.
If any library fails to install, update Python and pip before trying again.
| LED Color | Arduino Pin |
| ---------- | ----------- |
| Green LED | Pin 8 |
| Yellow LED | Pin 9 |
| Red LED | Pin 10 |
Connect the cathode (-) of each LED to GND through a 220Ω resistor.
Green LED -> Pin 8
Yellow LED -> Pin 9
Red LED -> Pin 10
All LED Cathodes (-)
↓
220Ω
↓
GND
Never connect LEDs directly to Arduino pins without a current-limiting resistor.
The Arduino continuously listens for commands sent by the Python application through USB serial communication.
| Received Character | Action |
| ------------------ | ------------- |
| G | Green LED ON |
| Y | Yellow LED ON |
| R | Red LED ON |
Only one LED remains active at a time.
The Python application captures live webcam video and tracks hand landmarks using MediaPipe.
The index fingertip position is compared against virtual zones on the screen.
Depending on the detected zone:
MediaPipe Index Finger Tip:
landmark[8]
This landmark is used as the cursor for controlling the virtual slider.
A horizontal slider is displayed at the bottom of the webcam feed.
The slider contains three sections:
A colored marker follows the user's fingertip position in real time.
When the marker enters a zone, the corresponding LED is activated.
The webcam captures live video.
MediaPipe detects the user's hand.
The index fingertip position is extracted using landmark[8].
The fingertip position is compared with predefined slider regions.
Python sends a serial command:
GYRArduino receives the command.
The corresponding LED turns ON.
The LED should update instantly as the finger moves.
Verify the COM port specified inside serial.Serial() matches your Arduino port.
Confirm that the Arduino sketch is uploaded successfully and that the USB cable supports data transfer.
Improve room lighting and ensure the entire hand is visible to the camera.
Verify wiring connections for Pin 8, Pin 9, and Pin 10.
Close applications such as Zoom, OBS, Discord, or Teams that may already be using the camera.
Additional LEDs can be assigned to unused Arduino digital pins.
Replace the three LEDs with an RGB LED and map finger positions to colors.
Implement custom gestures such as:
Replace LEDs with relays to control real-world devices using hand gestures.
After completing this project, you will understand:
This Gesture-Based LED Control System demonstrates how computer vision can be combined with embedded electronics to create intuitive touchless interfaces. By integrating Python, MediaPipe, OpenCV, and Arduino, developers can build interactive projects that bridge the gap between software intelligence and physical hardware control.