Pinterest Stumbleupon Whatsapp
Ads by Google

Hide this in your living room and laugh as the TiVo box is seemingly possessed by a demon that demands to watch cheesy shopping channels. Whether your ultimate goal is to turn off every TV in the neighbourhood or build a universal Siri-controlled remote, this project serves as a great starting point to learn the basics of IR control and receivers.

In this “prank”, we’ll be making a device that records, then plays back, a series of IR remote commands. It’ll work with any device that uses an IR remote control, or even a mix of devices at once – recording up to 10 key presses.

Components

Here’s a list of the things you’ll need for this project:

  • Arduino and patch wires
  • IR receiver, such as TSOP382 – but you should be able to find a compatible one in old electronics. I pulled mine out of a spare RGB lighting controller. They typically have 3 legs and are black, with one side looking like an LED that’s been chopped in half and stuck on. I’m sure there’s a technical word for that.
  • IR transmitter LED, such as TIL38 – again, these are pretty common, but I bought a new high power one from Maplin; they look identical to any other LED, so be sure not to get them mixed up in your electronics kit!
  • Suitable resistor for your IR LED – use this LED calculator given the supply voltage (5 V from the Arduino), and the forward voltage and current from the LED data sheet (usually around 1.2 V @ 20 mA). This came out as 220 ohms in my case.
  • Pushbutton, and 10k pulldown and 100 ohm resistors.
  • Download the IR remote library by Ken Shirriff from Github and place in your Arduino/Libraries folder. There’s also some example code we’ll use which should then be accessible from the Arduino Open -> Libraries menu.

components

Wiring

Tackle this circuit in three parts – the switch is a little fiddly, but everything else is easy. Remember the short leg of the LED with the flat face is the cathode (negative or ground); the long leg is the anode (positive).

circuit-diagram-ir-prank

Ads by Google

Receiving Signals

Go ahead and open up the libraries/IRremote/IRrecvDemo example code. Make sure the RECV_Pin is set correctly, compile and upload, then open up the Serial console at 9600 baud. Grab any remote you have to hand, aim it at your receiver and start pressing buttons. Different buttons will produce different codes; some will indicate a long press with the initial code then FFFFFF, while different remotes may simply repeat the code again.

irrecv

For a more detail view of the data being received, take a look at the IRrecvDump example instead, which will indicate both the type of signal received (32-bit NEC in this case), and the raw values. Good to know, but in most cases you’ll just want the decoded values.

irdump

Repeating a Signal

We won’t be writing our prank today from scratch, so go ahead and check out the IRrecord example. The code complexity increases greatly here, but it’s mostly all to cope with handle different types of IR codes – fundamentally, here’s what’s going on inside the loop:

  • Check for button being pressed, replay the currently stored signal if it is and repeat every 50 ms until depressed.
  • If not being pressed and a signal is detected, record that.

The biggest limitation of this example is that it only works with one code at a time, so if you press another remote button, it’ll overwrite the last one. The button simply replays the very last signal it received. Compile and run the code so you can have a go with this basic signal repeater. For playing back a single signal, it works fine, but that’s of little practical use in a prank or otherwise.

The Prank!

Let’s modify it slightly to record 10 or more mischievous signals. You can find the full modified code here, but here’s an outline of the changes I made in case you’d like to have a go programming this for yourself:

  • Define 3 new arrays of size 10 for storing a set of signals each time one is detected, and an integer to store the size of those arrays.
  • Store an index of where we currently are in that array. Increase index each time a signal is detected – but don’t increase if the signal is a repeat code.
  • A boolean value that stops more being recorded once we’ve reached the maximum.
  • A boolean to indicate if we’re in playback mode or not, rather than having to hold down the button; also modified the button logic to toggle this.

Note that the indicator LED on the Arduino (pin 13) will activate once the memory is full. Right now, you must record 10 button presses – no less – and replay mode will wait 1 second between each button replay. Here it is in action:

You can either play with making more IR pranks, or consider this a good start on a more epic home automation project Home Automation with Raspberry Pi and Arduino Home Automation with Raspberry Pi and Arduino The home automation market is flooded with expensive consumer systems, incompatible with one another and costly to install. If you have a Raspberry Pi and an Arduino, you can basically achieve the same thing at... Read More ; and don’t forget to check out all the other Arduino projects. Share your creations (or problems) in the comments, and please show your appreciation for this article by sharing it on your favourite social networks!

Image credit: DaGoaty

  1. Franky4
    April 21, 2016 at 10:41 pm

    When using Arduino Mega IR send pin must be 9 (OC2B).

  2. ?. ??????
    December 24, 2015 at 5:08 pm

    hi, I did the project on arduino it works , thanks , but i wanna simulate it on proteus but idk how to give ir signal on proteus. Can somebody help ?

  3. Archisman Dinda
    December 12, 2015 at 1:48 pm

    I do not get any output when I aim the remote at the reciever and press buttons.

    • James Bruce
      December 12, 2015 at 2:23 pm

      - The receiver is wired wrongly
      - It's not a receiver
      - It's not an infra-red remote
      - The wrong pin is set in the software

      Have you taken any steps to debug anything? Do you have any other remote control to test with to narrow down the problem?

      • Archisman Dinda
        December 12, 2015 at 2:52 pm

        - I checked with the reciever, it is wired correctly.
        - It IS a reciever.
        - It is an infra-red remote since all TV remotes are infrared remotes.
        - I've set pin 6 just like it is done in the picture.
        I do not how to debug it. I cannot figure out a way to figure out the problem. And yes, I used two remotes to check.

        Please help.

        • James Bruce
          December 12, 2015 at 3:07 pm

          Can you post a screenshot of your IDE and the serial console window open?

  4. really
    December 5, 2015 at 5:19 pm

    hey , when I verify the full modified code, compiler gave me

    sketch_dec02a:23: error: variable or field 'storeCode' declared void
    sketch_dec02a:23: error: 'decode_results' was not declared in this scope
    sketch_dec02a:23: error: 'results' was not declared in this scope
    sketch_dec02a:25: error: 'IRrecv' does not name a type
    sketch_dec02a:26: error: 'IRsend' does not name a type
    sketch_dec02a:28: error: 'decode_results' does not name a type
    sketch_dec02a.ino: In function 'void setup()':
    sketch_dec02a:33: error: 'irrecv' was not declared in this scope
    sketch_dec02a.ino: At global scope:
    sketch_dec02a:41: error: 'RAWBUF' was not declared in this scope
    sketch_dec02a:56: error: variable or field 'storeCode' declared void
    sketch_dec02a:56: error: 'decode_results' was not declared in this scope
    sketch_dec02a:56: error: 'results' was not declared in this scope

    what is wrong I dont understand

    • James Bruce
      December 6, 2015 at 7:32 pm

      Do you have the IRremote library installed correctly?

  5. undral
    November 27, 2015 at 2:31 pm

    the Code link is broken , Can you please fix it ?

    • James Bruce
      November 27, 2015 at 2:38 pm

      None of the links are broken, they're all loading fine for me. The IR remote library is still alive at the github link, and the pastebin has not been deleted. Which one are you looking at?

Leave a Reply

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