Hi guys,
I'm sharing with you a project I've recently done. I'ts about how you can control some LED's with a remote control and your Arduino. But you can apply this to any electronic device such as motors , lights for example.

you can visit my website for more electronic projects, interesting news and tips:

Step 1: IR library

First you need to go to this page and download the IR library. You just need to follow the read me file to install. I think that any IR remote control can do this, I’ll be using a Philips Universal one.
<p>LEDREMOTE.ino: In function 'void loop()':</p><p>LEDREMOTE.ino:112:5: error: expected ';' before '}' token</p><p>Multiple libraries were found for &quot;IRremote.h&quot;</p><p> Used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote</p><p> Not used: C:\Users\SERVER\Documents\Arduino\libraries\Arduino-IRremote-master</p>
<p>I also got the same error.</p><p>Add ';' at the end of line 111 - 'digitalWrite(ledPins[i], ledState);'.</p><p>It's too late for you but hope it helps someone else with same error.</p>
<p>Hi der, I've found a exciting website for dis.</p><p>http://vaaiibhav.me/how-to-use-arduino-with-infrared-remote-control/</p>
<p>am using TV remote to control my motor but i am getting an error can anyone fix it.</p><p>Also, after long pressing the button getting , i am getting a no. repeated for long press ,which is different than the first one.</p><p>#include &lt;IRremote.h&gt;</p><p>//ONKYO Remote</p><p>int RECV_PIN = 11; //Pin 11 is for the IR remote</p><p>IRrecv irrecv(RECV_PIN);</p><p>decode_results results; // The name of the decode_results function</p><p>int led = 13; // Pin 13 is for the builtin</p><p>LED on the arduino</p><p>const int Motor1Pin1 = 7; // Pins for the motors so 7, 6, 5, 4</p><p>const int Motor1Pin2 = 6;</p><p>const int Motor2Pin1 = 5;</p><p>const int Motor2Pin2 = 4;</p><p>void setup() {</p><p>irrecv.enableIRIn();</p><p>pinMode(led, OUTPUT); // OUTPUT the LED</p><p>pinMode(Motor1Pin1, OUTPUT); // OUTPUT the motor pins</p><p>pinMode(Motor1Pin2, OUTPUT);</p><p>pinMode(Motor2Pin1, OUTPUT);</p><p>pinMode(Motor2Pin2, OUTPUT);</p><p>}</p><p>void loop() {</p><p>digitalWrite(led, HIGH); // When the arduino is ready to get commands the LED will turn on</p><p>if(irrecv.decode(&amp;results)) { // if the arduino receives a signal from the remote...</p><p>irrecv.resume();</p><p>if(results.value == 0x4BB641BE) { // Here's where you need to change the value from</p><p>4BB641BE to the one in your serial monitor but always put 0x before the value (the number zero</p><p>and the letter x)</p><p>moveForward(); // move forward</p><p>}</p><p>else if(results.value == 0x4BB6C13E) { // Change the value for the Backward</p><p>moveBackward();</p><p>}</p><p>else if(results.value == 0x4BB621DE) { // Change the value for the Left</p><p>moveLeft();</p><p>}</p><p>else if(results.value == 0x4BB6A15E) { // Change the value for the Right</p><p>moveRight();</p><p>}</p><p>else if(results.value == 0x4BB6E916) { // Change the value for the Stop</p><p>Stop();</p><p>}</p><p>}</p><p>}</p><p>// voids for all the mouvement. If it doesnt work for you please feel free to change it</p><p>void moveForward() {</p><p>digitalWrite(Motor1Pin2, HIGH);</p><p>digitalWrite(Motor1Pin1, LOW);</p><p>digitalWrite(Motor2Pin2, LOW);</p><p>digitalWrite(Motor2Pin1, HIGH);</p><p>}</p><p>void moveBackward() {</p><p>digitalWrite(Motor1Pin1, HIGH);</p><p>digitalWrite(Motor1Pin2, LOW);</p><p>digitalWrite(Motor2Pin1, LOW);</p><p>digitalWrite(Motor2Pin2, HIGH);</p><p>}</p><p>void moveLeft() {</p><p>digitalWrite(Motor1Pin1, LOW);</p><p>digitalWrite(Motor1Pin2, HIGH);</p><p>digitalWrite(Motor2Pin2, HIGH);</p><p>digitalWrite(Motor2Pin1, LOW);</p><p>}</p><p>void moveRight() {</p><p>digitalWrite(Motor1Pin2, LOW);</p><p>digitalWrite(Motor1Pin1, HIGH);</p><p>digitalWrite(Motor2Pin1, HIGH);</p><p>digitalWrite(Motor2Pin2, LOW);</p><p>}</p><p>void Stop(){</p><p>digitalWrite(Motor1Pin2, LOW);</p><p>digitalWrite(Motor1Pin1, LOW);</p><p>digitalWrite(Motor2Pin1, LOW);</p><p>digitalWrite(Motor2Pin2, LOW);</p><p>}</p>
<p>If anyone is having trouble with getting this to compile go to your IRlibrary folder and delete the robot files then it will work thats what i did and works great</p>
<p>tried using the library file and got this error C:\Program Files (x86)\Arduino\libraries\RobotIRremote\IRremoteTools.cpp:5: error: 'TKD2' was not declared in this scope</p><p>tried copying and pasting from above and IRrecvDemo.ino: In function 'void loop()':</p><p>IRrecvDemo:112: error: expected `;' before '}' token</p><p>can you please advise</p>
<p>download IRremote library from link below</p><p><a href="https://github.com/z3t0/Arduino-IRremote/archive/master.zip" rel="nofollow">https://github.com/z3t0/Arduino-IRremote/archive/m...</a></p><p>after download, extract it and rename it and just delete &quot; Arduino-&quot; from it </p><p> copy it to arduino library folder</p><p>mine is :---- c &gt; program files (x86) / arduino / libraries</p><p>and paste it here </p><p>now restart your arduino software</p><p>go to: Files / Examples / IRremote / IRrecord</p><p>and compile it or verify it if there is no error then its done </p>
<p>i got the same problem please advice me what to do</p>
<p>I'm confused cos I'm a newb. Is the numbers after 'case' you know the 'case 59732'. are those the decodings of the remote ir signal?</p>
<p>Arduino: 1.6.6 Hourly Build 2015/07/21 05:42 (Windows 7), Board: &quot;Arduino Uno&quot;</p><p>IRrecvDemo.ino: In function 'void setup()':</p><p>IRrecvDemo:17: error: redefinition of 'void setup()'</p><p>sketch_jul26d:1: error: 'void setup()' previously defined here</p><p>IRrecvDemo.ino: In function 'void loop()':</p><p>IRrecvDemo:23: error: redefinition of 'void loop()'</p><p>sketch_jul26d:6: error: 'void loop()' previously defined here</p><p>Multiple libraries were found for &quot;IRremote.h&quot;</p><p> Used: D:\maitreya\Arduino\arduino-nightly\libraries\RobotIRremote</p><p> Not used: C:\Users\Maitru_2\Documents\Arduino\libraries\Arduino-IRremote-master</p><p>redefinition of 'void setup()'</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p><p>waht to do with this</p>
<p>This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p><p>Arduino: 1.0.6 (Windows 7), Board: &quot;Arduino Uno&quot;</p><p>In file included from sketch_jul26b.ino:23:</p><p>C:\Program Files (x86)\Arduino\libraries\RobotIRremote/IRremoteInt.h:187: error: 'RAWBUF' was not declared in this scope</p><p>what is the meaning of this</p><p>there comes this error</p>
<p>hey, I tried your project and it worked, but I have a little issues related to the distance at which I use my remote. The LEDs can only be switched at really short distances for me. Is it the same with you or my receiver isn't powerful enough ?</p>
<p>in this we have to just change the received value from ir after the word &quot;case...like case 1535313823&quot;...or to do sometng else..? plz help .</p>
<p>undefined reference to `IRrecv::IRrecv(int)'</p>
<p>collect2: error: ld returned 1 exit status</p><p>Error compiling.</p><p>please help:( i hv no idea what that means</p>
<p>Hi,when I want use serial monitor to see which values the arduino is receiving.</p><p>But I cannot see any value returned. Is that because I don't use the philips remote? </p>
<p>hi when i copy your code i get:</p><p>ir-led.ino: In function 'void loop()':</p><p>ir-led.ino:105:5: error: expected ';' before '}' token</p><p>Error compiling.</p>
That mean you have a syntax error on line 105...<br><br>In the IDE, click on settings and activate &quot;line number&quot; option... Go to the line 105 and fix ot
<p>Solved :) i missed this thingie &quot;;&quot; on line 105</p>
<p>C:\Program Files (x86)\Arduino\libraries\RobotIRremote\IRremoteTools.cpp:5: error: 'TKD2' was not declared in this scope</p><p>what is it asking for and how can I fix it</p>
<p>very nice project but i have some ir photodiode receiver can u give me sketch for it.</p>
<p>very nice project but i have some ir photodiode receiver can u give me sketch for it.</p>
<p>very nice project but i have some ir photodiode receiver can u give me sketch for it.</p>
<p>very nice project but i have some ir photodiode receiver can u give me sketch for it.</p>
<p>very nice project but i have some ir photodiode receiver can u give me sketch for it.</p>
<p>very nice project but i have some ir photodiode receiver can u give me sketch for it.</p>
<p>very nice project but i have some ir photodiode receiver can u give me sketch for it.</p>
<p>hello. I am trying to code this for only one LED for 1 button on the remote control to my television. Every time I try to modify your code, I always get a whole bunch of errors, but the most annoying one is &quot;Case label '********1' not within a switch statement. it always adds the 1 on the end, and I would like help on fixing this along with the other numerous errors that occumpany it. If you would please kindly ether message me or send code for only one led, that would be fantastic! great job by the way! Please respond!</p><p>Sincerely,Nic5153</p>
<p>I noticed that in the code you can change HEX to DEC to avoid the conversion.</p>
<p>Specifically the example code for IRrecvDemo</p>
<p>Amazing! Thanks for sharing this bro, this was my first project with an arduino. I was having a hard time at the beginning but it was because the pins of my receiver were different according to the datasheet. As an electric engineer. this could come pretty handy you could even control high power applications, instead of having a LED a relay would take place or a timer. Applications are limitless</p>
<p>Thanks dude this works perfectly for me.</p><p>I used this to operate a fan.</p>
<p>The only tiny error I found (beside a missing ';') is that the IR discovery sketch used to capture the IR codes from the controller calls for a different receiver pin, 11 if I remember, where your setup calls for pin 3. Once that change is made in the code, it captures the IR perfectly and then goes on to control the LEDs perfectly. I'm well on my way to my remote control swiveling ceiling mounted garage fan. Thanks. </p>
<p>Caro Rui, gostaria, se poss&iacute;vel, que me desse uma ajuda numa quest&atilde;o relativa ao IR a funcionar com o arduino e controlo de leds. Fa&ccedil;o modelos &agrave; escala, e no projecto que tenho em m&atilde;os gostava de aplicar luzes num cami&atilde;o &agrave; escala 1/8. Tenho tudo ligado, e quase a funcionar na perfei&ccedil;&atilde;o, mas ainda n&atilde;o consegui deixar os sinais de pisca a funcionar. Tenho tr&ecirc;s c&oacute;digos do IR disponiveis, para os piscas de esq. da direita e para os de emerg&ecirc;ncia. N&atilde;o consigo arranjar maneira de os deixar a piscar enquanto tenho outras luzes ligadas. Acha que me pode ajudar?</p><p>Obrigado desde j&aacute; pela paci&ecirc;ncia.</p>
<p>i love instructable site becauze they do alot of different crazy project</p>
<p>i love instructable site becauze they do alot of different crazy project</p>
<p>hi im trying to controll my arduino to move a servo. </p><p>(Could you help me put in the code?</p><p>The controll gives off the infrared as i press left: FF22DD and right FFC23D. Please help me figure this out.)<br><br> #include &lt;Servo.h&gt;<br> #include &lt;IRremote.h&gt;<br><br> unsigned long Value1 = 0xFF22DD; // where XXXXXXXX is on our your remote's values<br> unsigned long Value2 = 0xFFC23D; // where XXXXXXXX is another button on your remote<br><br> int RECV_PIN = 11;<br> IRrecv irrecv(RECV_PIN);<br> decode_results results;<br><br> Servo servo1;<br><br> // the setup routine runs once when you press reset:<br> void setup() { <br><br> Serial.begin(9600);<br> irrecv.enableIRIn(); // Start the receiver<br><br> // initialize the digital pin as an output.<br><br> servo1.attach(10); // attack servo to digital pin 10<br> }<br><br> // the loop routine runs over and over again forever:<br> void loop() {<br><br> if (irrecv.decode(&amp;results)) {<br> <br> Serial.println(results.value, HEX);<br> irrecv.resume(); // Receive the next value<br> }<br><br> if(results.value == Value1) {<br> servo1.write(160);<br> }<br> else if (results.value == Value2){<br> servo1.write(75);<br> }<br> } </p>
<p>here is the error I got</p><p>IRrecvDemo:16: error: 'IRrecv' does not name a type<br>IRrecvDemo:17: error: 'decode_results' does not name a type<br>IRrecvDemo.ino: In function 'void setup()':<br>IRrecvDemo:27: error: 'irrecv' was not declared in this scope<br>IRrecvDemo.ino: In function 'void loop()':<br>IRrecvDemo:32: error: 'irrecv' was not declared in this scope<br>IRrecvDemo:32: error: 'results' was not declared in this scope<br>IRrecvDemo:67: error: expected `;' before '}' token</p><p>thanks again,</p>
<p>You need to install the IR library...</p><p>You didn't follow throught the Step number 1.. Please read that step carefully.</p><p>Have a nice day,</p><p>Rui</p>
Dude the code is wrong!!
sorry for the long delay to answer... what you mean? it works fine for me and for a lot of people who already tried... <br>tell me what's not working, thanks!
hey dude what if i use a remote control which i got with the arduino starter kit? <br>thanks :)
what if I want to do this without using a library?
If you don't want to use the library, you'll need to write a lot of code to do this simple project. <br>What I recommend you to do is to download the library and my code. <br>See which functions I'm using from the library. <br>And understand what they do. <br> <br>Then instead of using the functions from the library you can create your own functions on a single Arduino skecth... <br> <br>I hope this helps, <br>Rui
I've installed the IRremote library. Opened iRrevc, compiled and uploaded to Arduino. All looks as it should yet nothing prints in the serial monitor. I've tried ALL the baud rates (although I imagine you used 9600) yet the issue persists. My circuit is identical to yours. Only difference in brand/model of the IR Receiver... I've tried 2. One I salvaged from an old sony blu ray player and the other I bought at RadioShack (276-0640). Both are:<br>38kHz IR receiver<br>Supply Current: 0.27-0.45mA<br>Supply Voltage: 2.5-5.5V<br>Output Volt low: 100mV<br><br>I've also tried several remotes that I've confirmed are in perfect working order.<br><br>Any thoughts on the matter? If you'd like, PM me. <br><br>Thank you!!
I follow your circuit diagram, but there are several problems <br>1. when I upload the code to Arduino, I keep get the wrong message that my Arduino port can't be read by my PC, but if I don't connect the ground and vcc from the circuit to Arduino, the port can be read by my PC. <br>2. After I upload the code (without connect the circuit and Arduino), I can't test my remote because the serial monitor can't be open if the circuit is connect to Arduino. <br>3. My IR receiver get hot when I connect it with Arduino. <br> <br>is that something I did wrong? or can you give me more explanations about how to read the remote. <br> <br>thanks.
thanks for trying my project! <br>1) I didn't understand exactly that problem... :S can you upload others arduino sketches to your arduino? did you upload the IR library to the libraries folder from the arduino IDE? <br>2) If the answer I gave you in 1) doens't apply to you... try to reinstall the arduino IDE again and try to upload my code. <br>3) which IR receiver you're using? <br>did you follow exactly my schematics? because that shouldn't be happening! <br>Please let me know what I can help you more with

About This Instructable




Bio: Author, Blogger, Electronics Enthusiast and Entrepreneur. For complete Electronics Projects and Tutorials go to: http://randomnerdtutorials.com/start-here
More by RuiSantos:ESP8266 Web Server (Without Arduino)Arduino Simple Memory GameArduino – Datalogger with Temperature Sensor and Photoresistor
Add instructable to: