Intro: Send Text to Arduino With IR Remote Control
In this instructable I am going to show you how you can use an IR remote control to send text data to an Arduino and display it on a LCD display. By using the number keypad on the remote control in the same way that you would a phone keypad to map digits to letters, you can write words on the LCD display. The display is updated whenever you press a button on the remote control. Special buttons can be assigned for moving the cursor forward and backward on the display and for clearing a character. The project is easily adapted to work with almost any remote control.
You can use this technique in your own projects if you want an easy and cost-efficient way to wirelessly send short text commands to an Arduino, e.g., for configuration purposes.
Step 1: Connect the Components
- Arduino Uno
- Jumper Cables
- TSOP31238 IR Receiver Module
- LCD Display (compatible with the Hitachi HD44780 driver)
- 1x Resistor 220Ω
- 1x Potentiometer 10kΩ
- IR Remote Control
Instead of the TSOP31238 IR receiver, you can also use a different type of receiver module. In my own build I used the 1838b module. The only thing to watch out for is that the module uses a carrier frequency of 38kHz. This is the carrier frequency that most IR remote controls use.
Connect the components as shown in the Fritzing sketch.
Step 2: Code
For this project I am using the following two Arduino libraries:
- The IRRemote library by shirriff
- The LiquidCrystal library by Arduino, Adafruit
Use the Library Manager in your Arduino IDE to install the libraries.
Map Codes to Buttons
Whenever you push a button on a remote control, it sends out some data, a few bytes, encoded as a sequence of rapid flashes of the IR emitter in the remote control (periods during which the IR emitter is on and periods during which it is off). Different remote controls send out different data when you push a button - this ensures that, for example, your TV remote doesn't turn on or off your DVD player. If you would like to learn more about how IR remote controls work and how they transmit data, I recommend that you read this tutorial from Sparkfun.
Since different remote controls send out different codes, the Arduino sketch I used in my project will at first probably not work with your remote control, because it contains the codes that my remote control is sending, which will most likely be different from the ones your remote is sending. But that's easy to fix! We can run the Arduino sketch in capture mode to capture the codes your remote is sending when you push the different buttons and then just insert the captured codes in the sketch, so it uses them when we switch back from capture mode to regular mode.
Follow these steps:
- Download the attached Arduino sketch
- Open the Serial Monitor in your Arudino IDE
- Upload the sketch to your Arduino
- The serial monitor should now ask you to press button "BUTTON_2" on your remote control
- When you press the button on your remote control, the serial monitor should tell you the code your remote control has sent
- Proceed in the same way until the serial monitor tells you that the capturing is done
- Find the section in the Arduino sketch where it says "REPLACE CODES HERE"
- Replace the codes in the sketch with the codes you just obtained for the corresponding buttons
- Comment out the line "#define CAPTURE_MODE"
- Upload the modified sketch to your Arduino
You can now use your remote control to send text to the Arduino!