Infra Red Cloning With Arduino

by RakaAmburo in Circuits > Arduino

169 Views, 3 Favorites, 0 Comments

Infra Red Cloning With Arduino

cloneSeriesInstruct.png
Infra Red Cloning With Arduino

Welcome again to a new Amburo tutorial. Many years ago I wrote a couple of publications related to cloning signals from radio devices and infrared devices as well. Even though it was a great achievement for me back then, now I see that there is still so much work to be accomplished and enhanced. So I decided to resume this job and give the final touch... a list for now. 

So I decided to embark on this new cloning series. In which I will be enhancing this previous works of mine. I will be improving the way signals are captured in order to make the process of cloning a set of signals more practical. Also refining the code to prepare it to assemble it with a client interface on the computer side to control the cloning and emiting.

We will start with infrared cloning. I suggest you go and review this work so you get a grasp on what I am trying to accomplish.

old publication

Supplies

irCloneSupplies.png

We will be using an Arduino Uno, an emitter board, a receiver board, and some cable for the wiring. Bear in mind you can just use a simple emitter and receiver but you will have to add the required components to make it possible. In the case of the emitter, you can plug in directly the LED in pin 13 since Arduino has a resistor incorporated on that pin. please take a look at this publication:

IR emitter

Connections

irConn.png
connectionBread.png

As you can see with this little board connections have no mystery. Both boards work with 5v so if you want them to be connected at the same time, you will have to use a breadboard. to feed the positive line and connect both boards. Or you can just simply take turns to clone and emit.

Code Intro

irclonecode.png

In short, the idea behind this is to make it super easy to clone as many signals as you want and test them right away. As you may know, remote control devices using infrared signaling use different protocols to structure the signaling depending on the brand and maybe also on the type of device. But in the end, it all goes down to a combination of timings that an LED is turned on and turned off during a period of time basically milliseconds.

Based on this we will use the core Arduino function attachInterrupt() to link a function to a specific pin input (the IR receptor) that will be storing the time in microseconds between changes of this pin state (on/off) in an array. The attachInterrupt() basically hardwires the pin input to a certain logic, making it suitable for things that happen in an ultra-fast fashion.

Then once we have stored the signal we will print it as a sequence of numbers separated by a comma finalized by an ampersand symbol marking the end of the signal. Once we have that sequence we will be able to copy it and send it to test if it works. So let's see the code.

irClonerAndEmitter.ino

Code

DIVEDEEPirclonecode.png

First thing first, you will see that I updated the code so that it contains both cloning and emitting functions. You will be able to clone and test it right away. For that, you have in the loop function the code that reads the Serial expecting 1 or 2 for clone and emits respectively. 

The cloning function will clear the signal-storing array and set the attachInterrupt() with a very simple function that stores the timeout. Followed by a while loop that will be looping until a stop signal is inputted, represented as a pipe character (this basically is in case you want to halt the process). Or until signalsPointer variable is greater than 0 which means that a signal is incoming. We wait until the signal is completed (this number may vary but so far is enough). We detach the function preventing any other casual interrupt and simply print the array as we explained earlier.

On the other side, the command represented by the character 2 will ignite two functions. First the reading of the single from the serial. So basically Arduino will wait until you paste the signal cloned previously. Yes, this is kind of tedious but we will solve this process very soon. For now, it will suit us just fine for testing purposes. As you can see this function readSignalsFromSerial is kind of large but it has no mystery. Simply reads each character, joins the number as one after each comma with the help of the utility array oneSignal, and detects signal ending and the stop action explained before. Notice at the beginning of each action we clear the array with the function memset for starting over.

The second function sendSignal, will be looping the signal array which will execute each pulse by turning on and off, or waiting sequentially for each signal. So basically you see that the signals represent interleave periods of pulsing and waiting.

Two things to point out here. First, you will see the use of MemoryFree library. Basically, this is for checking that the memory of our Arduino is not overflowing, you can remove those if you want. Since we are reusing a large array. I found it handy to check the Arduino memory. Second, you see the printing of different strings like WAITING_4_SIGNAL. We will use those not only to see that the commands are being executed correctly, will use them to implement a client interface on the computer side to handle all the processes and store the signals as well. Bear in mind this will remove the necessity of copying and pasting signals, which, by the way, I find very annoying. I will present this interface in the next tutorial.

Last But Not Least

shield.jpeg

Finally, you will see that am testing this with a shield that I made basically to make it easy to plug and unplug the receptor and emitters for both radio and IR. As you can see is not very neat I found it very hard to solder all the little cables and sockets, but finally, it served its purpose extremely well. You can simply connect the different boards (radios and IRs) as explained in original cloning publications.

What Is Next

irConingwhatIsNext.png

As I mentioned, in the next tutorial of this series, I will be presenting an interface that has the capability of controlling the Arduino board through the USB. So basically we will be able to clone, store, and emit signals (among other functionalities) with simple cmd commands without the need to copy and paste large strings.

See you in the next one and have a good one.