Introduction: Control Your Arduino With a Remote
Wondering about how to control anything in your house with a simple remote control? It's pretty simple and cheap.
Step 1: Collect Stuff
Here is what you will need:
- Arduino (I use UNO)
- Solderless breadboard
- An infrared receiver
- Solderless wires
- Any kind of remote control
Step 2: Assemble the Receiver
Plug in the ir receiver to the beradboard and connect it to your Arduino.
Connect the right pin to the 5V of the Arduino, the center pin to GND, and the left pin to digital pin 11.
Step 3: The Code
I used the IRremote library for arduino.
You can download it here: IRremote
Close the Arduino IDE and unzip it into the arduino/libraries folder.
Start Arduino IDE and open the IRrecvDemo example sketch. Rewrite "HEX" to "DEC" as the image shows.
Upload the sketch to your board.
Step 4: Identify Remote Buttons
After uploading the program open the serial monitor and start pushing the buttons on your remote. If you have done everything well, you have to see the codes appearing.
Remember which button was pressed and take notes of the codes appearing.
For example:
Code 50088119 appeared and you pressed the On/Off button.
Code 50073839, Open/Close button etc...
Step 5: Control Stuff
Now you know which code the buttons give. To control something you have to write them into the program.
Here is the code you have to use. It's not the best solution I think but it's simple.
switch(results.value){
case 50088119:
// do something
break;
case 50073839:
// do something else...
break;
}
Have fun ;)
59 Comments
3 years ago
I got this error message when I tried to verify-
sketch_jan21a:12: error: 'IRrecv' does not name a type
Please help. I am new to arduino...
3 years ago
I have receive only FFFFFFFF from AC remote .what is problem ?
4 years ago
this works without the computer connected ?
Reply 4 years ago
yup, just give it a power source thru the circular port.
4 years ago
when i try to send the file to my arduino uno, it gives me this error message=
GetFileAttributesEx C:\Users\user\Downloads\IRremote\IRremote\examples\IRrecvDemo\IRrecvDemo.pde: The system cannot find the file specified.
Error compiling.
Reply 4 years ago
so what do i do?
9 years ago on Step 5
hi im sorry to bother you again but i was wondering if it is possible to block a certain value from being wrote to the serial
F7708F
F7708F
FFFFFFFF
FFFFFFFF
F7708F
F7708F
F7708F
F7708F
F7708F
FFFFFFFF
F748B7
FFFFFFFF
F748B7
F748B7
FFFFFFFF
FFFFFFFF
i want to block the F's
Reply 9 years ago on Step 5
It is not neccessary but if it disturbs you simply write an if statement to filter the F-s.
Reply 9 years ago on Step 5
i am a little new to arduino and i was using this with winlirc and the config was picking up the F's
Reply 5 years ago
Hi, i saw your post and I'd like to know if you managed to use WinLirc with Arduino? Does arduino make the IR decoding?
Reply 9 years ago on Step 5
I really don't know winlirc so sorry i don't have an idea :S
Reply 9 years ago on Step 5
its good i just need to block the FFFFFFFF string cause its picking it up as a remote code causing false readings. could you help with that part cause i have tried and failed
Reply 9 years ago on Introduction
Insert this:
if(results.value != 4294967295){
Serial.println(results.value, DEC);
}
4294967295 is the decimal value for FFFFFFFF
The F-s won't be shown ;) enjoy
Patrik
Reply 9 years ago on Introduction
Awesome now to figure the rest on my own lol
i didnt think bout inverting the line
5 years ago
I need to do a function only while I'm pressing a key of the remote, which means that the function stops when I take my hand off the button. How can I write the program to that? Plz help!!!
5 years ago on Introduction
For some reason its trying to read from the RobotIRremote library. Should I delete or move the folder as i am using an UNO?
Here are my errors:
Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:1: error: missing terminating " character
int RECV_PIN = TDK2"; // the pin the IR receiver is connected to
^
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TDK2' was not declared in this scope
int RECV_PIN = TDK2"; // the pin the IR receiver is connected to
^
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp: In function 'void beginIRremote()':
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:10:2: error: 'irrecv' was not declared in this scope
irrecv.enableIRIn(); // Start the receiver
^
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp: In function 'bool IRrecived()':
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:14:9: error: 'irrecv' was not declared in this scope
return irrecv.decode(&results);
^
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp: In function 'void resumeIRremote()':
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:18:5: error: 'irrecv' was not declared in this scope
irrecv.resume(); // resume receiver
^
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Reply 5 years ago on Introduction
I have deleted it and now it says there is no IRremote.h but there is!!
5 years ago on Introduction
in expansion of macro 'HEX'
Error compiling.
and
expected unqualified-id before numeric constant
#define HEX 16
are causing me problems
7 years ago
hi please help me i already had all the codes for the IR
what if i want to light 2 leds with the IR? which connections should i make? am new please hlep :(
Reply 5 years ago on Introduction
I think you'll have to take two (or four) button's readings and apply them to two different LEDs.
Something like:
switch(results.value) {
case 1:
digitalWrite(13,HIGH);
break;
case 2:
digitalWrite(12,HIGH);
break;
case 3:
digitalWrite(13,LOW);
break;
case 4:
digitalWrite(12,LOW);
break;
}