29 August, 2015

Arduino: scan codes from a remote control

There are different types of infrared remote controls produced by different companies: for TV, DVD and other consumer electronics. As well all of them can be reused for Arduino using an infrared sensor.

Different remote controls may have different sets of codes, so first you need to determine what code is sent by each button. It is simple. Just connect IR sensor with Arduino:

Arduino Uno + IR sensor

Run this program:

#include <IRremote.h>

const int IR_PIN = 10;

IRrecv irrecv(IR_PIN);

decode_results results;

void setup() {
  Serial.begin(9600);  
  irrecv.enableIRIn();
}

char chars[9] = {};

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume();
  }
  delay(100);
}

*It uses IRremote library.

Open serial monitor, press some buttons on the remote control and see the output:

Serial print scanned codes

Program prints codes for pressed buttons. For example, a remote control from the Samsung SmartTV sends these codes for numeric buttons:

  • E0E020DF 1
  • E0E0A05F 2
  • E0E0609F 3
  • E0E010EF 4
  • E0E0906F 5
  • E0E050AF 6
  • E0E030CF 7
  • E0E0B04F 8
  • E0E0708F 9
  • E0E08877 0

No comments: