arduino remote control

12
Arduino Remote Control In this tutorial, we look into Arduino remote control! When I was designing this robot, I wanted to use radio control, just like the kind used with remote control cars and planes you find at toy stores. It wouldn‟t be too hard to implement this for an Arduino robot by hacking an old toy or just buying a new receiver/transmitter combo, but in the interest of keeping this tutorial as simple and cheap as possible (it is intended for beginners) while building a complete robot. I decided to use an infrared remote kit since you can get everything you need for under $10. I think this approach is great for a beginner, but it does have the disadvantage that you must have line of sight to the robot to control it, and thus the range of the receiver is less than it would be with remote control, but at under $10 it you can hardly go wrong. After building your robot, you can upgrade to radio control, and hack the remote to control your neighbors TV and have some fun from just outside their window. Here is the infrared remote kit I used. You could also hack an existing remote control, probably you have one laying around from an old TV or VCR ( remember those). I could not find much documentation on this little kit, and it didn‟t come with any, so I ended up reverse engineering it to figure out what commands it sends, and then programmed the Arduino to respond to those commands. I found an excellent code Library online that was written by Ken

Upload: adalberto-sharpley

Post on 20-Jul-2016

37 views

Category:

Documents


6 download

DESCRIPTION

In this tutorial, we look into Arduino remote control!

TRANSCRIPT

Page 1: Arduino Remote Control

Arduino Remote Control

In this tutorial, we look into Arduino remote control!

When I was designing this robot, I wanted to use radio control, just like the kind used with

remote control cars and planes you find at toy stores. It wouldn‟t be too hard to implement this

for an Arduino robot by hacking an old toy or just buying a new receiver/transmitter combo, but

in the interest of keeping this tutorial as simple and cheap as possible (it is intended for

beginners) while building a complete robot. I decided to use an infrared remote kit since you can

get everything you need for under $10. I think this approach is great for a beginner, but it does

have the disadvantage that you must have line of sight to the robot to control it, and thus the

range of the receiver is less than it would be with remote control, but at under $10 it you can

hardly go wrong. After building your robot, you can upgrade to radio control, and hack the

remote to control your neighbors TV and have some fun from just outside their window.

Here is the infrared remote kit I used. You could also hack an existing remote control, probably

you have one laying around from an old TV or VCR ( remember those).

I could not find much documentation on this little kit, and it didn‟t come with any, so I ended up

reverse engineering it to figure out what commands it sends, and then programmed the Arduino

to respond to those commands. I found an excellent code Library online that was written by Ken

Page 2: Arduino Remote Control

Shirriff , which has all the code we need to reverse engineer the remote. You will need to

download this library from git hub and import it into the Arduino IDE.

start by navigating to https://github.com/shirriff/Arduino-IRremote and clicking on download ZIP

Copy the downloaded zip file from your downloads folder or wherever you saved it to, and

navigate to your Arduino directory.

Page 3: Arduino Remote Control

paste the zip file in the “libraries” directory under the Arduino directory. The name as

downloaded is too long and gives me an error when I try to import it. I renamed it to “IR”

Page 4: Arduino Remote Control

next we need to import our new library into the Arduino Software. First create a new sketch and

call it “IR_test”, or something else you like. Then Click on

Sketch->Import Library->IR

Page 5: Arduino Remote Control

next add the following code ( which is also from Ken Shrirriffs blog)

#include <IRremote.h>;

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()

{

Serial.begin(9600);

irrecv.enableIRIn(); // Start the receiver

}

void loop() {

if (irrecv.decode(&amp;results)) {

Serial.println(results.value, HEX);

irrecv.resume(); // Receive the next value

}

Page 6: Arduino Remote Control

}

we now have enough code to reverse engineer the remote, first lets check that the remote is

transmitting, there will be a little plastic tab that is inserted in battery compartment of the remote

when you receive it, remove that tab. The remote works by flashing an infrared led, this occurs

at a wavelength that is invisible to the human eye, but its not invisible to most digital cameras.

next we need to hook up the IR receiver that came with our remote. Here is the circuit diagram

for what we need to do. Set this up, upload the code above to the Uno, and open up the Serial

Monitor ( make sure the baud rate is correct).

Page 7: Arduino Remote Control

If you have everything hooked up correctly, you will see output on the Serial monitor every time

you push a button. You‟ll want to write these down, we are going to need them later. Here is the

Serial Monitor output I got from pushing the remote buttons

Page 8: Arduino Remote Control

here is a list of the translations I got for each button. Notice all the „FFFFFFFF‟ entries, these

are “repeat” commands, and if you hold a button down, you get a constant stream of

„FFFFFFFF‟. This will make programming the robot a bit more tricky, but we‟ll get to that a little

later. I recommend you check these for yourself.

Page 9: Arduino Remote Control

——————————————————————————-

PWR FD00FF

——————————————————————————-

VOL+ FD807F

——————————————————————————-

FUNC/STOP FD40BF

——————————————————————————-

|<< FD20DF

——————————————————————————-

>| FDA05F

——————————————————————————-

>>| FD609F

——————————————————————————-

DOWN FD10EF

——————————————————————————-

VOL FD906F

——————————————————————————-

UP FD50AF

——————————————————————————-

0 FD30CF

——————————————————————————-

EQ FDB04F

——————————————————————————-

ST/REPT FD708F

——————————————————————————-

1 FD08F7

——————————————————————————-

2 FD8877

——————————————————————————-

3 FD48B7

——————————————————————————-

4 FD28D7

——————————————————————————-

5 FDA857

——————————————————————————-

6 FD6897

——————————————————————————-

Page 10: Arduino Remote Control

7 FD18E7

——————————————————————————-

8 FD9867

——————————————————————————-

9 FD58A7

——————————————————————————-

Now just to see how easy it is to reverse engineer a remote to be an arduino remote control, go

grab a few from around the house if you have them, and see what kind of output you get from

those. Here are two that I used.

Using the exact same circuit and program as above, here is the output I got from a directv

remote.

Page 11: Arduino Remote Control

And here is the output from a Helo TC smartphone controller helicopter.

Page 12: Arduino Remote Control