Decoding Black or White Remotes with Arduino

Decoding Black or White Remotes with Arduino

In this tutorial, we will learn how to decode the keys from black and white infrared remotes using an Arduino and an IR receiver. By the end of this project, you will be able to determine which key has been pressed on the remote and display that information on the serial monitor. This can be useful for controlling devices with any remote you may have, such as TVs or other appliances (in video at 01:00).

Deconding-IR-remote-main

We will be using a simple setup that includes an Arduino, an infrared receiver module, and the necessary code to decode the signals. The infrared receiver will capture the signals from the remote, and the Arduino will interpret those signals to determine which button has been pressed. This project is straightforward and can be adapted for various remote controls.

Deconding-IR-remote-main-2

Hardware Explained

The primary components for this project include the Arduino board and an IR receiver module, typically designated as VS1838B. The Arduino will serve as the main controller, executing the code that processes the signals received from the remote. The IR receiver captures the infrared signals emitted by the remote control and converts them into a format that the Arduino can understand.

IR remote receiver VS1838B pins
IR remote receiver VS1838B pins

The VS1838B operates at a voltage range of 2.7V to 5.5V, making it compatible with most Arduino boards. It can detect signals from a distance of 10 to 15 meters, depending on the conditions. The infrared receiver outputs a digital signal that indicates which button on the remote has been pressed, allowing the Arduino to respond accordingly.

Datasheet Details

Manufacturer VS1838B
Part number VS1838B
Logic/IO voltage 2.7–5.5 V
Supply voltage 5 V
Output current (per channel) 1.5 mA
Receiving distance 10–15 m
Input frequency 38 kHz
Quiescent current 0.8 mA (typ.)
Angle of operation 70 degrees
Package TO-220

 

  • Ensure proper voltage supply to avoid damaging the IR receiver.
  • Keep the receiver module away from direct sunlight or strong infrared sources.
  • Use pull-up resistors if necessary to stabilize the signal readings.
  • Wiring connections should be secure to prevent intermittent signals.
  • Test different remotes to see how well they work with the setup.
  • Deconding-IR-remote-main-1

Wiring Instructions

To wire the IR receiver to the Arduino, first connect the VCC pin of the IR receiver to the 5V pin on the Arduino. Next, connect the GND pin of the receiver to one of the GND pins on the Arduino. Finally, connect the signal pin (often labeled as SIG or OUT) of the IR receiver to digital pin 11 on the Arduino.

Make sure that the connections are secure, as loose connections can lead to inconsistent readings. If you are using a PCB version of the IR receiver or a bare module, the wiring remains the same; just ensure that you identify the pins correctly as per the module's labeling (in video at 03:15).

Install IRremote library

Launch Arduino IDE. (you get from Arduino.cc for free) Click on library icon on the left and search for    IRremote and click on "Install" to install it. 

#include <IRremote.h>

Code Examples & Walkthrough

int RECV_PIN = 11;
const char type ='W'; // W for white, B for black
const boolean PCB = 0; // 1 for PCB, 0 for bare module
IRrecv irrecv(RECV_PIN);

In this excerpt, we define the pin number for the IR receiver with RECV_PIN set to 11. We also specify the type of remote being used with the type variable, where 'W' indicates a white remote and 'B' indicates a black remote. The PCB variable distinguishes between using a PCB version of the receiver or a bare module.

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

In the setup() function, we initialize the serial communication at 9600 baud and start the IR receiver. This is crucial for monitoring the output on the serial monitor, allowing us to see which key has been pressed.

void loop() {
  if (irrecv.decode(&results)) {
    robojaxValidateCode(results.value); // Validate the received code
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

The main loop() checks if the IR receiver has decoded a signal. If it has, it calls the robojaxValidateCode function to process the value received and then resumes listening for the next signal. The delay(100) ensures the loop doesn't run too quickly, which can help with signal processing.

Demonstration / What to Expect

Once everything is set up and the code is uploaded, open the serial monitor to see the output. When you press a key on the remote, you should see the corresponding key name displayed on the monitor. If the key is not recognized, it will display "Key unknown." Make sure to press keys firmly, as loose connections can cause erroneous readings (in video at 05:40).

If you press a key continuously, the output may show repeated values or hexadecimal codes. This behavior is normal, and you can modify the code to filter out these continuous signals if desired. Additionally, you can adjust the code to perform actions based on specific key presses, such as turning on lights or controlling other devices.

Video Timestamps

  • 00:00 Start
  • 00:56 Hardware is Explained
  • 04:26 Wiring Explained
  • 05:20 Code is explained
  • 12:27 Demonstration of code decoding

图像

Decoding any black remote or white remote with Arduino
Decoding Any Black remote or White remote with Arduino
IR remote receiver VS1838B pins
IR remote receiver VS1838B pins
Deconding-IR-remote-main
Deconding-IR-remote-main
Deconding-IR-remote-main-1
Deconding-IR-remote-main-1
Deconding-IR-remote-main-2
Deconding-IR-remote-main-2
137-Source code for decoding infrared remote controllers using Arduino
语言: C++
已复制!

|||您可能需要的东西

资源与参考

尚无可用资源。

文件📁

没有可用的文件。