My Bluetooth Remote Control Robot kit also comes with a Keyes Infrared remote sensor and a command .
You’ll need to install the IR Remote library for this to work. You can get it from github – Arduino-IR. To install, just follow the instructions provided in the README file.
If you want, you can learn a bit more about the IR protocol in the Ken Shirriff’s blog (link below).
This sensor has three PINS, from left to right : GND (-), VCC (2nd PIN), SIGNAL (S).
Let’s connect this to the Arduino. The signal PIN connect to digital PIN 11 (If you choose another, please change it in the sketch below).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <IRremote.h> //include the library //PIN int receiver = 11; IRrecv irrecv(receiver); //create a new instance of receiver decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); //start the receiver } void loop() { if (irrecv.decode(&results)) { //we have received an IR Serial.println (results.value, HEX); //display HEX irrecv.resume(); //next value } } |
Here is the result, from pressing buttons on the remote:
References
http://tronixstuff.com/2011/03/30/tutorial-arduino-and-infra-red-control/
http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
Error on this sketch
C:Program FilesArduinolibrariesRobotIRremotesrcIRremoteTools.cpp:5:16: error: ‘TKD2’ was not declared in this scope
int RECV_PIN = TKD2; // the pin the IR receiver is connected to
Wat to do, i am a beginner.
Thanks Bert
Hi Bert !
You’re a bit scarce with the details. That’s a file from the downloaded libraries ?
How is your sketch ?
Try this pages:
http://tech.cyborg5.com/irlib/
http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
Best regards
Can you tell me what is wrong?
Still not working.
Greetings Bert
Hi Bert !
What libraries did you download ?
You have to download the correct libraries and put them in the libraries folder – after that, you must rename the library.
If you download the one i mention in here, after you download it and unzip it, you must renamed it to IRremote . After that, close the Arduino IDE and open it again.
For your error, and following the path, you didn’t rename it to IRremote – You leaved it as RobotIRremote… You must rename the folder to IRremote – (Again, if you have the Arduino IDE open, you must close it and open it again !
Hope that helps.
Best luck !
http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
Hello.
Here is the sketch, your sketch I thought.
My English is poor , sorry.
The specified error message I get when I send the sketch to the Arduino.
Am I doing something wrong?
greetings Bert
#include
IRsend irsend;
void setup ()
{
Serial.begin (9600);
}
void loop () {
if (Serial.read ()! = -1) {
for (int i = 0; i <3; i ++) {
irsend.sendSony (0xa90, 12); // Sony TV Power code
delay (100);
}
}
}
This is the code.
I've done the steps to give up. and rename to IRremote
The error remains the same.
At every sketch.
Arduino version 1-0.6
Greetings Bert
Hello Ken.
It works !!
I have reset everything, including the P.C
The I.R now displays the code on the screen.
I often see FFFFFF among the other code.
Is that normal?
Many thanks for your help
70 years old but not too old to learn.
Greetings Bert.
http://www.bertheideveld.nl
Hi,
I’m curious what protocol the remote control shown on this page follows… Is it NEC?
Thanks,
-Krispin
Hi !
I really don’t know if any ! It’s a cheap remote that comes in bundles from dx.com
Not working yet!
sketch_feb25a.ino: In function ‘void loop()’:
sketch_feb25a:11: error: ‘amp’ was not declared in this scope
sketch_feb25a:11: error: expected
)' before ';' token
;’ before ‘)’ tokensketch_feb25a:11: error: expected
Hi Wagner !
Please remove the amp; word from your code and replace it with the ampersand character. It’s a typo that got there when I migrated my blog from another server. My apologies.
I’ll update the code !
It should be “irrecv.decode(&results)”
Your page was incredibly helpful in making my hardware work. A massive thanks from Toronto – your work is greatly appreciated!
Thanks.
Thank you Mike !
I’m just sharing the knowledge !
my English is poble, apologies.
that is led that comes in the kit, thanks
hi,where i find the right librarie???i know you put a link,but i cant find the librarie
Hi Brunce !
Heres the Link again: https://github.com/z3t0/Arduino-IRremote
Instructions:
In the right side of the github page, there’s a button to download a ZIP with all the files.
Once you download it, unzip it and move the resulting directory – from “Arduino-IRremote-master” to “IRremote” – and move it to your Arduino libraries folder.
Close the Arduino IDE and open it again. Now you should have the library available to you.
Best luck
Bruno Santos
Hi, i’m new to arduino world, the code works fine, but i didn’t understand the object declared on line 5:
decode_results results;
Its probably a stupid doubt.
Thanks
Hi Karl.
Is not a stupid doubt, is pertinent.
decode_results is a structure (of the library) that will decode the information received – if you give a look into the examples of the library – the IRrecvDump example, you will understand it .
Cheers
Arduino: 1.6.8 (Windows 7), Board: “Arduino Due (Programming Port)”
In file included from C:\Users\Hesham\Documents\Arduino\libraries\IRremote\IRremote.h:24:0,
from C:\Users\Hesham\Documents\Arduino\libraries\IRremote\IRremote.cpp:25:
C:\Users\Hesham\Documents\Arduino\libraries\IRremote\IRremote.cpp: In function ‘void TIMER2_COMPA_vect()’:
C:\Users\Hesham\Documents\Arduino\libraries\IRremote\IRremoteInt.h:92:26: error: ‘PORTB’ was not declared in this scope
#define BLINKLED_ON() (PORTB |= B00100000)
^
C:\Users\Hesham\Documents\Arduino\libraries\IRremote\IRremote.cpp:189:10: note: in expansion of macro ‘BLINKLED_ON’
else BLINKLED_ON() ; // if no user defined LED pin, turn default LED pin for the hardware on
^
C:\Users\Hesham\Documents\Arduino\libraries\IRremote\IRremoteInt.h:93:27: error: ‘PORTB’ was not declared in this scope
# define BLINKLED_OFF() (PORTB &= B11011111)
^
C:\Users\Hesham\Documents\Arduino\libraries\IRremote\IRremote.cpp:191:10: note: in expansion of macro ‘BLINKLED_OFF’
else BLINKLED_OFF() ; // if no user defined LED pin, turn default LED pin for the hardware on
^
Multiple libraries were found for “IRremote.h”
Used: C:\Users\Hesham\Documents\Arduino\libraries\IRremote
Not used: C:\Program Files (x86)\Arduino\libraries\IRremote
exit status 1
Error compiling for board Arduino Due (Programming Port).
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
I keep getting the above error? any idea what to do ?
Hi HESHAM !
I believe that you have multiple IRremote libraries and Arduino doesn’t know which one to use. Second, the error reported is on the library and not in your code.
I haven’t used an Arduino Due so I can’t comment if that’s something with that, but it doesn’t appear to be.
Please remove all of the libraries for IRremote and try this one:
https://github.com/enternoescape/Arduino-IRremote-Due
Is for Arduino Due – i think the more recent versions don’t support it already.
Best regards
Hey guys,
If I keep receiving multiple values for the same button. What seems to be the issue?
Appreciate it!
Hello.
If you recieve only FFFFFFFF code, check for LD on IR reciever. If it blinks, but you do not touch the remote – it is overwhelmed by some IR source. Try to shield it and try again.
libraries\RobotIRremote\IRremoteTools.cpp.o:(.bss.irrecv+0x0): multiple definition of
irrecv'
sketch\sketch_nov29a.ino.cpp.o:(.bss.irrecv+0x0): first defined here
libraries\RobotIRremote\IRremoteTools.cpp.o: In function beginIRremote()’:
D:\Mixly0.94\arduino-1.6.9\libraries\RobotIRremote\src/IRremoteTools.cpp:14: multiple definition of `results’
sketch\sketch_nov29a.ino.cpp.o:C:\Users\Milky_Way\Documents\Arduino\sketch_nov29a/sketch_nov29a.ino:11: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1