Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: Can't get IRrecvDemo example to work as expected  (Read 1307 times)
0 Members and 1 Guest are viewing this topic.
Belgium
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I bought the DFRobot IR Remote controller kit and tried to use it with the IRrecvDemo.
Many applications can be found that are based on the IRrecvDemo, but none seem to work for me.
Without making changes to IRrecvDemo, I tried it with IDE 23 but my Serial.print always shows 8 character values rather than the 6 character values as illustrated below




 I always get 8 digit hex codes like these:

25802501
CBD2CCFD
FFFFFFFF
57E346E1
D9EF995E
B1EFBA9D
B1EFBA9D
6E2B307C
6BFD8B01
1E29FBFF
925D5B5D
1E90961
FFFFFFFF

As a result the code cannot work

Code:
else if(results.value==0xFD906F)
{
motor(-40,-40);
}


I'm sure the hardware is OK, the sample code  found here http://www.dfrobot.com/wiki/index.php?title=IR_Kit%28SKU:DFR0107%29 works OK. Note that this sample code does not use the IRremote.h library.


Any help would be appreciated.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 671
Posts: 51669
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
As a result the code cannot work
You can specify any value that the device received as the value to match to:
Code:
if(results.value==0xD9EF995E)
{
   // Got D9EF995E...
}
Logged

Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 184
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Post your code.
Logged

Belgium
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



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
  }
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 671
Posts: 51669
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code that tries to use the values that you have recorded, not the code that printed them.
Logged

Belgium
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm at the office right now, can't access the sketch I used to test.
I"ll post it tonight.
Thanks so far.
Logged

Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 184
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the exact same IR remote.

One side note:
The FFFFFFFFs are the remote sending the repeat code if you hold the button down too long.
Logged

Belgium
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the code. For testing I only added to check if the  "VOL +" button is pressed.

Results are not very consistent and I wonder why I don't see the codes as shown here



as explained on this page http://www.e-shore.com.my/homepage/all-projects/193-ir-remote-control-mobile-robot.html

Do various versions of this remote exist ? I would expect them to use the same hex codes

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);
   
    if(results.value==0xC9C3741)
      {
      Serial.println("VOL + pressed");
      }
      else
      {
      Serial.println("other button pressed");
      }   
    irrecv.resume(); // Receive the next value
  }
}
Logged

Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 184
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This line
 if(results.value==0xC9C3741)

Should be:
  if(results.value==0xFD807F)

Yes, I have one that is physically and coded the same but has a different plastic overlay.
http://www.adafruit.com/products/389
Logged

Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 184
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I downloaded your code, put my fix on it and it decodes the VOL+ equivalent key on my remote.
It decodes all of the remote's keys.

There may be a problem in your hardware.  Please post good pictures so that individual wires/connections can be traced.

JOe
Logged

Belgium
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have this one
http://www.dfrobot.com/index.php?route=product/product&product_id=366

and apparently it generates different codes


My code works but sometimes buttons are missed and I have to press again to get a positive result.

I was confused because I thought I read abnormal HEX codes  but I looks like a have an  IR remote control that sends different codes.



Logged

Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 184
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree with you, the code is fine.  I also believe that the remote control is correct.

There is something else going on, battery in the remote control is bad or something is wrong in the arduino hardware. 
Good luck. 
Logged

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: