# Hacking on the TV remote control

**Do you have an old TV remote?** What if I told you that you could create your code to communicate with this remote controller? We can do it.<br>

![](/files/smqcoQoJN5CS2UlydEgB)

### The story tale around TV Remote controller

The infrared remote control is excellent. The idea of this git chapter is to turn it into a presentation tool. It is easy with this remote to keep your finger on the advance button and advance slides — or turn the screen back to your favourite PDF viewer. Like MacGyver, to handle a problematic situation through improvisation using only available materials to do an intellectual activity soon. It's ok. Let us go to the hack.

## The motivation

There are several potential motivations for creating a custom driver for Linux to read TV remote inputs and perform actions on a computer. One motivation is to enable users to control their computers using a TV remote, which can be more convenient and user-friendly than a keyboard or mouse. This can be particularly useful for applications designed to be used with a TV, such as media players or games.

Another motivation for creating a custom driver is to enable users to customize the behaviour of their TV remote. By writing a custom driver, you can specify which buttons on the remote correspond to which actions on the computer, and you can even add new features and functionality to the remote. This can make it easier for users to use their TV remote how they want, and it can make their overall experience more personalized and enjoyable.

Finally, creating a custom driver for Linux can also be a challenging and rewarding learning experience. It can help you improve your programming skills and your knowledge of Linux and driver development, and it can be a fun and exciting way to explore new technologies and techniques.

### &#x20;The f**irst step you need to get some things**

* Computer with Unix Like OS(at my tests Fedora Linux)&#x20;
* Any TV remote control (my control [samsung model “AA59-00469A”](http://www.amazon.com/Samsung-Remote-Control-AA59-00469A-Batteries/dp/B009JVN73I))&#x20;
* [Arduino nano](https://www.arduino.cc/en/Main/ArduinoBoardNano) 12,00 USD&#x20;
* IR recv (model “1838B”) - 2,00 USD&#x20;
* Jumpers 1,00 USD&#x20;
* Breadboard 2,50 USD

\
The total cost is 17.50 USD, looks good and is not expensive, try following this image to assembly your hardware:

![](/files/heM11cy9JE3UqpxQHpXf)

### Explain each resource

* The green wire is GND&#x20;
* The orange wire is 5v&#x20;
* The yellow wire is pin 6(this is input  to make communication with Arduino)&#x20;
* USB connected at Arduino(usually at mini-series uses [FTDI ](http://www.ftdichip.com/)input)

### Mapping the context

Second step mapping your TV remote control:\
At this step, we are getting some libraries. Look at the following:

* `$ git clone https://github.com/shirriff/Arduino-IRremote`&#x20;
* `$ mv Arduino-IRremote ArduinoRemote; sudo cp -rf ArduinoRemote/ /usr/share/arduino/libraries`&#x20;

\
At your Arduino IDE tool, you can view examples of use it at the tab "File", load examples that show the input of serial, and look the following:

![](/files/6FM7Lme38DEi0gCrUgr9)

The function Serial.println() shows the output of the serial input. For example: when you hold the button on one of the TV remote control, [this action shows the hexadecimal value "E13DDA28".](https://github.com/CoolerVoid/arduino_ppt_walk/blob/master/IR_remote.c#L152)

### The communication

Done the mapping process of buttons, the next step is to use [syscall](http://man7.org/linux/man-pages/man2/syscall.2.html) open() to open the file "/dev/ttyUSB0" and use the syscall read() to get INPUTs of the Arduino device. Remember to put different conditions at each button input of the device.\
\
To automate keyboard hold keys, at Unix like a system, you need to use some libraries like libXtst and libX11, to emulate keys to turn screens of presentation. To install this library, look the following:

**`$ yum install libXtst-devel libX11-devel`**\
So **deb-based distros uses apt-get install pkg\_name-dev**\
\
To get the final code, [rewrite this lines 152 and 159 with the address of your button mapping,](https://github.com/CoolerVoid/arduino_ppt_walk/blob/master/IR_remote.c#L152)  compile it and run:\
\&#xNAN;**`$ git clone https://github.com/CoolerVoid/arduino_ppt_walk`** \
\&#xNAN;**`$ gcc IR_remote.c -o IR_remote -lX11 -lXtst -Wall`**\
\&#xNAN;**`$ ./IR_remote /dev/ttyUSB0`**

### Proof of concept

Look at the following:

{% embed url="<https://www.youtube.com/watch?v=Wx64BfLgxQU>" %}

**Thank you for reading.**&#x20;

![](/files/YBPwX9hwZE0nTRZgFnmc)

**Cheers!**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://antonio-cooler.gitbook.io/coolervoid-tavern/hacking-on-the-tv-remote-control.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
