Hi,
I want send instructions to my arduino with remote control and IR receiver (buy a ebay kit).
It's my IR receiver :
I download the good library and tested a simple example. Here is my code :
/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#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(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
Example scheme, replace 2 to 11...
My result :
0
FFFFFFFFF
0
FFFFFFFFF
0
FFFFFFFFF
0
FFFFFFFFF
0
FFFFFFFFF
...
But that should be the good result...
And sometimes , when I press a button on the remote control, it's okay... randomly... but really sometimes.
Can you help me ?
Thanks
Lauszus
September 23, 2011, 2:04pm
2
It might be because you are using an unsupported remote? Try a different remote or alternative us the "IRrecvDump" example:
/*
* IRremote: IRrecvDump - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
// decode_results *results = (decode_results *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.println("Could not decode message");
}
else {
if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
for (int i = 0; i < count; i++) {
if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" ");
}
Serial.println("");
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
dump(&results);
irrecv.resume(); // Receive the next value
}
}
how sure are you that the remote sends the same frequency the receiver accepts?
Any data sheets? BTW, 38khz seems to be a common frequency used in remotes.
system
September 24, 2011, 8:56am
4
Post the model name of the IR receiver.
also try a diffrent remote.
Thanks for answers.
I buy a kit, so the remote and the battery are news (i think).
And I also tried with others remotes, same result.
Sometimes, it's work... 5%.
Maybe the IR Receiver is damaged ?
Can you provide a link to the kit?
jimford
September 28, 2011, 10:00am
7
I bought one like this, expecting to have problems with it - but it worked 'out of the box':
http://www.ebay.co.uk/itm/IR-Receiver-Module-Wireless-Remote-Kit-Arduino-/220820431320?pt=LH_DefaultDomain_3&hash=item3369ec61d8#ht_638wt_892
(I don't think it was from this seller, though.)
Jim