Sunday, November 24, 2024

Arduino Based Windows PC Volume Remote Control

Presented here is a project that turns your Arduino into a remote control. Infrared (IR) remotes have been very prominent since 1980’s. In today’s world almost everything is controlled by a remote. This project allows you to control the master volume of a Windows PC, a television set, set-top box, home theatre system and the like.

Standard Data Formats

There are two common data formats for IR control: RC5 coding and NEC coding.

RC5 Code

RC5 code uses a bi-phase coding, and the carrier frequency is fixed at 36kHz. Transmission of the data begins with two start bits followed by a toggle bit (Fig. 1). Toggle bit changes its value at each new key press. Five address bits represent the address of the device to be controlled. Six command bits contain the information to be transmitted.

- Advertisement -
RC5 transmission code (Image courtesy: www.vishay.com)
Fig. 1: RC5 transmission code (Image courtesy: www.vishay.com)

Each bit in the data consists of half a bit period with no transmission and half a bit period with a burst of 32 pulses at 36kHz. The most suitable IR receivers for receiving RC5 code are those with AGC2 setting and a band-pass frequency of 36kHz. Some examples are TSOP1236, TSOP4836, TSOP34836, TSOP39236 and TSOP36236.

NEC Code

NEC code uses bursts at a carrier frequency of 38kHz. It starts transmission using a leader code, a burst with a length of 9ms, followed by a pause of 4.5ms and then the data (Fig. 2). The original purpose of this leader code was to let the internal control loops in the receiver modules to settle.

- Advertisement -
NEC transmission code (Image courtesy: www.vishay.com)
Fig. 2: NEC transmission code (Image courtesy: www.vishay.com)

After transmitting the data, only the leader code and a single bit are transmitted repeatedly for as long as a key is pressed. A special property of this code is a constant word length in combination with pulse distance modulation.

Address and data bits are transmitted twice, first as a normal byte, followed by an inverted byte. The half period burst portion of each bit contains 22 pulses, each with a width of 8.77µs and a period of 26.3µs. 0 is represented by a pulse distance of 1.125ms, and 1 by a pulse distance of 2.25ms.

Eight address bits are used to identify the device to be controlled. Further eight bits are used for transmission of command data. As mentioned above, the words are always followed, without a pause, by inverted words. For example, transmission of address 00110111 and command data 00011010 is performed by sending bits as:

“00110111’11001000’00011010’11100101”

In a special version of NEC code, the pre-burst, including all address and data bits, is repeated in each 108ms time slot for as long as the key is pressed.

IR receiver modules

The most suitable IR receivers for receiving NEC code are those with AGC4 setting as these have the best noise suppression while still supporting this data format. Some examples are TSOP4438, TSOP58438 and TSOP75438. Receiver modules for different carrier frequencies are given in the Table above.

Circuit and Working

Circuit diagram of Arduino PC volume control is shown in Fig. 3. Hardware components required are Arduino Uno, TSOP1738 IR receiver, breadboard and some jumper wires.

Circuit diagram of Arduino based Windows PC volume remote control
Fig. 3: Circuit diagram of Arduino based Windows PC volume remote control

Working of the project is fairly simple. Arduino Uno decodes the key of the remote and then compares it with predefined variables to figure out which key is pressed. If it finds a match, it sends the signal to the PC, which is interpreted by Remote Volume Control software (designed by author), which further performs the required task. Screenshot of Remote Volume Control software is shown in Fig. 4. The most important step is to configure the desired remote control device with Arduino Uno.

Fig. 4: Screenshot of Remote Volume Control software

Software

The source codes (IR_Key_Test.ino and IR_Final.ino) are written in Arduino programming language. The software used to program Arduino Uno is Arduino IDE, which can be downloaded free of cost from www.arduino.cc/en/Main/Software

Arduino, which is an open source software, makes it easy to write and upload the code to the board. It runs on Windows, Mac OS X and Linux. The environment is written in Java and based on Processing and other open source software.

The library used in this project is IRremote library. It allows Arduino Uno to decode IR signals coming from the remote. To install the library, copy IRremote folder and paste it in the following location:

Documents>Arduino>libraries folder
To communicate between Arduino Uno and PC, mode of communication used is serial communication. You need to install Remote Volume Control software on the targeted PC, which communicates with Arduino Uno and accordingly performs the task. This software runs in the background and automatically starts when the PC boots.

Initial setup

Step 1:

To configure your desired remote control device, install IRremote library and open IR_Key_Test.ino code from Arduino IDE. Select the correct board from Tools→Board menu in Arduino IDE, and burn the program (sketch) through the standard USB port in your computer.

Step 2:

After uploading the code, open Serial Monitor in Arduino IDE. Point the remote control towards TSOP receiver module and press the key that you want to assign for volume up function continuously. Note the key code number that will repeat again and again when the key is pressed. Screenshot of the example is shown in Fig. 5.

Example of key configuration
Fig. 5: Example of key configuration

Key code for volume up function as per current serial data is 45135. Note that some remotes send value 65535 or FFFF after sending the key code. Sometimes, there might be abrupt values due to ambient light or interference, so take five to six readings before assigning the key code. Similarly, repeat the above procedure to find the key codes for volume down and mute functions.

Step 3:

After noting down the key codes for all functions, open IR_Final.ino code and write down your key codes as shown in Fig. 6. Save and compile the code.

Screenshot of IR_Final.ino
Fig. 6: Screenshot of IR_Final.ino

Testing the Project

After uploading IR_Final.ino code to Arduino Uno, connect it to your PC and open Device Manager. Note the COM port assigned to Arduino Uno.

Device Manager window
Fig. 7: Device Manager window

Download source code

Here, Arduino Uno is assigned COM3 (Fig. 7). Install Remote Volume Control software and start it. Select COM3 in COM Ports menu and select 9600 baud rate from Baud Rate menu. Click on Connect, and if all goes well, volume of the PC will be controlled by your desired remote. The author’s prototype of Arduino based Windows PC volume remote control is shown in Fig. 8.

Author’s prototype
Fig. 8: Author’s prototype

Arnav Bansal is an electronics hobbyist and loves to tinker with circuit designs

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Electronics News

Truly Innovative Electronics

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics