กลับไปหน้ารวมไฟล์
controlling-vlc-media-player-with-your-hands-using-arduino-348131-en.md

In this project, I am going to be using Arduino and Python to control the VLC Media Player with just my hands. Read on further to learn how to do this project.

Hardware components used in this project

  • Arduino Nano
  • Breadboard Power supply module - 3.3/ 5V
  • Solderless Breadboard - Half+
  • IR line tracking sensor module (x2)
  • Male-to-Male Jumper wires (x2)
  • Female-to-Male Jumper wires (x6)

Softwares used in this project

  • Arduino IDE - Version 1.8.10
  • Python 3.8

Hardware Setup

Your setup must look somewhat similar to those in the pictures above.

Connections

IR line tracking sensor module

  • (+) - 5V
  • (-) - Ground (GND)
  • S1 - D3
  • S2 - D4

Coding

You will need to use both Python and Arduino IDE for this project. Before moving on to the coding of this project, let me guide you to install the Python software along with some important python modules.

Download the software from here. I would recommend you to download the latest compatible version for your OS. In this project, I will be using Python 3.8.1 as it is the latest version as of now.

Next, you will need to install the PyAutoGUI module and pyserial module to make this project work. Download these modules by following the hyperlinks below:

Installing PyAutoGUI and pySerial modules

Install the python software and open command prompt. Change the directory to the folder where you have installed the software. PIP is a packet management system that lets you install and manage software packages written in python. You will need to upgrade PIP before you install these modules. In order to do this, you will need to use the following function:

python - m pip install - upgrade pip

Install the PyAutoGUI module by typing the following function in your command prompt, after PIP is upgraded:

python - m pip install pyautogui

Repeat the process to install the Pyserial module after the installation of PyAutoGUI module is completed. You will be needing the following function for this:

python - m pip install pyserial

The next step is to check whether these modules are successfully installed. Open the Python IDLE and type 'import serial'. If the module was successfully installed, your Python shell will look something similar to this:

Arduino coding

We have successfully installed the Python software and the essential modules. Now, I will explain you about the coding done in Arduino.

  • Play/ Pause - Place your hands in front of both IR sensors
  • Increase Volume - Place your hand in front of the IR sensor which is on the right
  • Decrease Volume - Place your hand in front of the IR sensor which is on the left

Create global variables for the sensors. You could name the variables as 'Right' and 'Left'. Within void setup( ), call pinMode( ) to configure the IR sensors' pins as INPUT. Set the data rate in 9600 baud (bits per second) for serial data transmission.

The IR line tracking sensor module will detect objects which are within 8mm from the IR sensor and sends a LOW signal to the Arduino microcontroller when it detects an object. Within void loop( ), program your Arduino Nano microcontroller to execute the functions explained above.

If both the sensors send a LOW signal, then the serial monitor must print 'Play/ Pause' and set a delay period of 500 milliseconds.

If the sensor on the right sends a LOW signal and the sensor on the left sends a HIGH signal, then the serial monitor must print 'Increase Volume' and you should add a delay period here as well.

If the sensor on the right sends a HIGH signal and the sensor on the left sends a LOW signal, then the serial monitor must print 'Decrease Volume' and set a delay period of 500 milliseconds.

Set a delay period of 300 milliseconds before completing the void loop( ) function.

Python coding

Now let's move on to the coding in Python. Open the Python IDLE and open a new file. Import the modules which we installed in the first step along with the time module. You will be needing the time module to use delay function. Create serial port object and open serial port. You can find pg.11 of this documentation useful for this process. Wait for 3 seconds while the communication establishes.

After the communication is established, read the serial data and print it. If the serial data received is 'Play/ Pause', then the typewrite function must be used to press the spacebar for 0.3 seconds.

You will be needing the PyAutoGUI module, so this website can be helpful in learning the functions of this module.

If the serial data received is 'Increase Volume', use the hotkey function. The arguments for this function in this case will be 'ctrl' and 'left'. Open VLC media player and press the 'ctrl' key and left arrow key to see the volume level increasing.

Repeat the same process for 'Volume down' but the arguments in this case must be 'ctrl' and 'right'.

Code snippet:

If anyone has questions with the coding, please feel free to comment below.

Final Look

EXPANDED TECHNICAL DETAILS

Computer-Vision Assisted Haptic Control

This high-tech project allows you to control the VLC Media Player using physical hand gestures, bridging Arduino hardware with Python-based AI.

  • Python Media-Pipe Integration: A PC running Python 3.8.0 uses a webcam to identify hand gestures (like "Open Palm" or "Fist"). The Python script then sends a specific serial trigger to the Arduino.
  • Serial-to-Keylink Bridge: The Arduino receives the command and acts as a USB HID device, sending the corresponding VLC shortcut key (e.g., 'f' for Fullscreen, 'p' for Play).

Interaction

  • Dynamic Gesture Thresholding: The Python script includes a "Confidence" check to ensure accidental hand movements don't trigger media commands, providing a professional and stable gesture interface.

ข้อมูล Frontmatter ดั้งเดิม

title: "Controlling VLC Media Player with your hands - Using Arduino"
description: "In this project, I am going to be using Arduino and Python to control the VLC Media Player with just my hands."
author: "RucksikaaR"
category: ""
tags:
  - "infrared"
  - "python"
  - "sensor"
  - "automation"
views: 2907
likes: 1
price: 1120
difficulty: "Intermediate"
components:
  - "1x Solderless Breadboard Half Size"
  - "1x Arduino Nano R3"
  - "2x IR tracking sensor module"
  - "2x Male/Male Jumper Wires"
  - "1x SparkFun Breadboard Power Supply 5V/3.3V"
  - "6x Male/Female Jumper Wires"
tools: []
apps:
  - "1x Python 3.8.0"
  - "1x Arduino IDE"
downloadableFiles: []
documentationLinks: []
passwordHash: "04dcb90290bf43650912fe31615a94ea37bfe2b3bde5c854260de08981334201"
encryptedPayload: "U2FsdGVkX18G+lmcLRsGlp350hZy48r69UEKQUVqW90hCYurlb5S3Ira6b8wjGNZbBNKOvM2F22rYuKCzcHPGuOrex7CcTzuo39f/4x+lPF4sJFrcG7zm/nCNpVxd4GO"
seoDescription: "Learn to control VLC Media Player using hand gestures with Arduino and Python in this DIY project."
videoLinks:
  - "https://www.youtube.com/embed/e_QhtUlE-0A"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/controlling-vlc-media-player-with-your-hands-using-arduino-348131_cover.jpg"
lang: "en"