Control your Arduino using an Infrared Remote and the IK38khz sensor

In this article we’ll send data from a classic IR remote controller (I used my Creative Speaker IR remote control) to turn on/off a LED in our Arduino board, using an IK38khz sensor and the IRemote library.

Naturally you could use your IR Remote for everything: to manage motors, servo and other devices or you could also create a cheap network between two Arduino: one board will send data from a IK38khz Sensor (receiver) and the other one will receive them using an infrared Led (sender)

So, first of all, create your prototype circuit getting inspiration from the next image

2009_11_15_infrared-ik38khz-universal-remote-control_circuit

1) LED is connected to pin 13.
2) IK38khz on pin 9

NOTE: be sure to connect Ground and Power to the right pins otherwise you could destroy your sensor (i have a lot of experience about this ; )

Copy following sketch to your microcontroller:

#include <irremote.h>
 
int RECV_PIN = 9;
int ledPin =  13;
 
IRrecv irrecv(RECV_PIN);
 
decode_results results;
 
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(ledPin, OUTPUT);
}
 
void loop() {
 
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
 
    if(results.value == -2094865891)
      digitalWrite(ledPin, LOW);   // set the LED on
    else
      digitalWrite(ledPin, HIGH);   // set the LED on
 
    irrecv.resume(); // Receive the next value
  }
}

In the IF condition I have simply turned off the LED on pin13 when the result is -2094865891 (the value I get when I click the VOLUME button on my remote control). Instead, when another button is clicked the Led is turned off.

You can get your IR remote button values checking the Serial Monitor, thanks to the Serial.println().

NOTE: I’m a Flash/Flex developer and i’m not so inside electronic stuff to be sure this is the best way to proceed.
It’s just a cheap and quick way : )

ISSUES: I have tested this script with 3 remote controllers:
1) the Creative one is what I use to write this article and it works.
2) My TV controller (SHARP LCD) return 0 from every button, so i couldn’t use it.
3) My ALICE TV remote control (an italian internet provider) return nothing for every button, so it doesn’t work too.

I got inspiration from following article, where you can download the IRemote Libray and get more details about this stuff:
http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html .

Comments (3)

  1. Ken Shirriff (reply)

    January 19, 2010 at 8:26 am

    I’ve extended my IRremote library to work with more types of remote controls. The details are here. Hopefully this will work with your TV controllers; let me know.

  2. edwin (reply)

    September 29, 2012 at 7:41 am

    other remotes don’t work as they have a signal more than 32 bis wide
    tried and troubleshooted myself for project(propeller clock)

  3. AnalysIR (reply)

    July 3, 2013 at 11:05 pm

    Hi Guys
    For anyone interested in IR protocols – we have just launched a Crowdfunding campaign on IndieGoGo for AnalysIR – IR Decoder & Analyzer (Arduino & Raspberry Pi). Currently we support 17 IR protocols and are looking for more to add as part of the campaign. Suggestions Welcome!

    You can find out more about the Campaign on http://bit.ly/1b7oZXH or Screenshot via http://www.AnalysIR.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Published on: 15 November 2009
Posted by:
Discussion: 3 Comments