Few days ago, I needed a second monitor.
I decided to use the LG TV that has been in the house since the day my family moved in.
However, the remote was missing and the touch button was broken.
After giving it some thought, I decided to make a remote control myself.
I think it would have been simpler if I just fixed the buttons, but we make dumb choices 🤷.
The modules used in this project is as follows:
3 push-buttons (power, confirm, settings)
joystick (for navigating)
The library used for sending IR signals is IRremote.
Circuit and Photos
The program used for making the circuit is Circuit.io.
It doesn’t have that many default modules to play with, but it is a web application and also free (which is very convenient).
The cables are spaghetti, but it works!
Let’s go through the codes line by line.
(also for the future me when I decide to come back to it)
Put it simple, initialization for the push buttons and the IR transmitter is done in the setup, and loop is constantly waiting for user input.
The user can use the three buttons to turn on/off the monitor, open the settings menu, and confirm.
In addition, the user can navigate through the menu screen using the joystick.
Starting from the beginning,
This part is getting the IR library and declaring the variables necessary for sending the IR signals.
As stated in the comments, LG has a similar protocol to NEC.
Although it’s a post from 2017, LG’s IR protocol has a total of 32 bits for data which is divided into four 8 bits.
The first part is called the Low Custom and the second part is the same but inverted.
The next two parts are also similar, but are labeled as Command.
The protocol that I have just explained is very similar to NEC.
Since the code for sending in NEC protocol sends it LSB first, I used the MSB first method. (which is the LG way)
Here, the variables (such as pin and command) related to the buttons and joystick used for user input is initialized.
This is the function for reading joystick input where x and y values are used to decide the direction.
I think this part could have been coded better.
Same as the function for the joystick, this is the function for the push buttons.
On push, IrSender.sendNECMSB() is called which is the function for sending the MSB first.
This last part quite summarizes the whole code in one page.
Here, the buttons and the IR module are initialized and awaits for user input to send.
The project started rather unexpectedly, but it was a great opportunity to actually use and learn IR protocols.
In the beginning, I barely knew the difference between RF and IR, but after many trial-and-errors and the useful resources on the net, I was able to fix the problem with the monitor and successfully create a fully functioning IR remote with an Arduino.
Unfortunately, after the connection was made using the remote, the monitor started to recognize the desktop and the remote was no longer needed…
If you want to learn about IR, I recommend starting with this video.
The video explains the characteristics of IR and its implementations through an example project which I found extremely informative.