Pinterest Stumbleupon Whatsapp
Advertisement

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

Advertisement

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

Leave a Reply

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