Introduction: Arduino XboxOne, TV, and Fan Remote Control

Picture of Arduino XboxOne, TV, and Fan Remote Control

In this instructable I will show you how to use an Arduino infrared (IR) remote control shield I made so that you can make a control for all your devices and say goodbye to multiple controls and AAA batteries.

If you can't get the shield don't worry, I will also have steps to cover you.

Step 1: Result

Watch the result of following this tutorial in the video above. You can also pretty much learn how to do it by following the video instead of reading if you'd like, but you will have to read if you want to know how the circuit is made.

I know I know, this is usually the last step, but I like to show the result first to get people excited about the tutorial.

Note: You cannot use the remote to play XboxOne games, it can only be used to navigate media menus.

Step 2: Reason Behind Project

Reason #1: I have many electronic devices which can be controlled using infrared (IR) signals: TVs, fans, an XboxOne, even a light bulb.

The problem with this is that you also end with with a control for each device. Even worse, the control's paint might wear off leaving you to guess which key you are pressing, it might break, you might lose it, or it might run out of batteries.

Reason #2: I found out that the XboxOne supported IR signals (even without a Kinect) and I just HAD to make an Arduino shield and code for it and other devices.

The IR receiver is located on the XboxOne console to the right of the eject button.

Step 3: Decoding IR Signals (Circuit and Software)

Circuit:

If you have an Infrared Shield you are good to go.

If you don't the have Infrared Shield you can still follow this step by doing the following:

You can easily decode IR signals with your Arduino using a TSOP382 and the Infrared Shield Library for Arduino.

  1. Connect a TSOP382 as shown in page 1 of the TSOP382 datasheet's Application Circuit (attached here). The "OUT" pin of the TSOP382 will need to be connected to pin 4 of your Arduino.

Software:

  1. Load the IR Receiver Dump example into your Arduino.
  2. Open the Arduino serial monitor window.
  3. Grab the IR controls you want to get rid, then point their IR led to the TSOP382 and press the key(s) you'd like to decode.

You should see an output similar to the following:

Decoded NEC: FF609F (32 bits)
Raw (68): -16246 8950 -4500 600 -550 550 -600 500 -600 550 -550 600 -550 550 -550 550 -600 550 -550 550 -1700 550 -1650 600 -1700 550 -1700 550 -1650 600 -1700 550 -1650 600 -1650 600 -550 600 -1650 600 -1650 550 -600 550 -550 600 -550 550 -550 550 -600 550 -1650 600 -550 550 -600 500 -1700 600 -1650 600 -1650 550 -1700 600 -1650 600 

Where, in this case, "NEC" is the control's IR protocol, and "FF609F" is the key's IR code in HEX.

The "Raw" array of numbers is a representation of each of the IR signals pulse in microseconds (us) staring with a high pulse then a low pulse and alternating until the entire signal has been read.

In the example above "-16246 8950 -4500 600" means 16246us HIGH, 8950us LOW, 4500us HIGH, 600us LOW.

Note: If you wish to use a raw code instead of its HEX value you'll have to clean it up by removing the first element (-16346) and removing the negative sign (-) from all other elements.

In the example above the resulting raw code after cleaning would look like this:

8950 4500 600 550 550 600 500 600 550 550 600 550 550 550 550 600 550 550 550 1700 550 1650 600 1700 550 1700 550 1650 600 1700 550 1650 600 1650 600 550 600 1650 600 1650 550 600 550 550 600 550 550 550 550 600 550 1650 600 550 550 600 500 1700 600 1650 600 1650 550 1700 600 1650 600

If you wish to learn how to change an NEC raw code to a HEX number by hand (just for fun), check out this web page about the NEC protocol. To help you get started, in the raw code above:

  • 8950us (which is almost 9000us) corresponds to the starting HIGH pulse of 9ms (1000us = 1ms) in the NEC protocol.
  • 4500us corresponds to 4.5ms
  • and 600us 550us would be a "0" bit (two 562.5us pulses, one HIGH, and one LOW)

Step 4: Sending IR Signals (Circuit and Software)

Circuit:

If you have the Infrared Shield you are good to go.

If you don't have the Infrared Shield, do the following:

  • Connect an IR LED with a current limiting resistor to digital pin 9 in the Arduino
  • Alternatively, SparkFun sells this awesome IR emitter kit in which case you would connect "CTL" to digital pin 9 in the Arduino.

Software:

To send an IR signal/code, load up the example called "Send_Without_Button_Press" from the Infrared Shield Library, replacing the HEX number for IR_CODE with the code you'd like to send

Note:The example uses a code for the NEC protocol, if your signal was given a different protocol by the decoder example such as "SAMSUNG" instead of "NEC" then use the appropriate function i.e. irsend.sendSAMSUNG

Step 5: Assigning IR Codes to Buttons

If you have the Infrared Shield you can assign codes to buttons this way:

#define XBOX_ONE_UP      0x011B7887

  // configure UP button
  irControl.setButtonCode(
    IRControl::buttonUP, // button ID
    IRControl::NEC, // IR protocol
    XBOX_ONE_UP, // ir code to send when this button is pressed
    32 // length of ir code
  );

Note: See the example called TV_XboxOne_Fan_Control for an entire Arduino sketch.

If you don't have an Infrared Shield:

  1. Connect a button or switch to a digital pin in the Arduino.
  2. Use an if statement to check if the button was pressed
  3. If the button was pressed send the code.

Example Code:

#include <AllAboutEE_IRsend.h>

using namespace AllAboutEE;

#define IR_CODE 0x20DF40BF
#define BUTTON_PIN 10

IRsend irsend;

void setup()
{
 pinMode(10,INPUT);
}

void loop()
{
    if(digitalRead(BUTTON_PIN)==HIGH){
    irsend.sendNEC(IR_CODE,32); // 32 is the number of IR bits in the code.
    }
    
}

Comments

jaknieper23 (author)2016-03-13

good work on this

tomatoskins (author)2015-05-19

This is awesome!

About This Instructable

4,658views

39favorites

More by AllAboutEE:Arduino XboxOne, TV, and Fan Remote Control
Add instructable to: