Control Your Arduino With a Remote

41,062

90

59

Published

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 ;)

Share

    Recommendations

    • Oil Contest

      Oil Contest
    • Clocks Contest

      Clocks Contest
    • Woodworking Contest

      Woodworking Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    59 Comments

    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...

    I have receive only FFFFFFFF from AC remote .what is problem ?

    yup, just give it a power source thru the circular port.

    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.

    1 reply

    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

    7 replies

    It is not neccessary but if it disturbs you simply write an if statement to filter the F-s.

    i am a little new to arduino and i was using this with winlirc and the config was picking up the F's

    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?

    I really don't know winlirc so sorry i don't have an idea :S

    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

    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

    Awesome now to figure the rest on my own lol
    i didnt think bout inverting the line

    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!!!

    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.

    1 reply

    I have deleted it and now it says there is no IRremote.h but there is!!

    in expansion of macro 'HEX'
    Error compiling.

    and

    expected unqualified-id before numeric constant
    #define HEX 16

    are causing me problems

    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 :(

    1 reply

    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;

    }