IR remote issues (decoding results)

I have an Ir receiver powered up with 5v and the output pin is connected to the arduino uno's pin 11. I have an ir transmitter (a remote).

The aim of my setup is to decode the instruction sent from the remote (I.e a integer) and display the result in the serial monitor.

The problem i encountered is, when i press a button on the remote, i get a different result from when i press and hold that same button.

Is this normal??
I want to control a robot car with this signal, i.e when up key is pressed move forward.

How can i go about this

include<IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);
decode_results  results;

void setup(){ 
Serial.begin(9600);
irrecv.enableIRIn();

}

void loop(){
if (irrecv.decode(&results)){

Serial.println(results.value);
irrecv.resume();

} 

delay(100);

}

What is the code did you received while holding a button - something like 0xFFFF ?
If so, it is a perfectly normal behaviour. Many IR transmitters sends i.e. "repeat the last knob" code to indicate the long press of the same button.

It looks like.
Please post a link to the datasheet of that unknown IR receiver.
One pin connected to UNO pin 11, one pin to 5 volt. No more pins?
A little schematics made by pen and paper, please.

The ir receiver have three pins, vcc, gnd and out.
Vcc connects to 5v pin of the arduino uno
Gnd connets to gnd pin of the arduino uno
Out connects to pin 11 of the arduino uno

When i hold and press the button, i get this value.
4294967295 and this value is same if i hold and press any button.

It is 0xFFFFFFFF in hex, "repeat code"
So read my answer above

I'm confused if this would affect the control of the robot car. Because i want the car to move when i press and hold the button.

Or is it impossible to implement based on the configuration of the remote??

Why this could prevent you to use the remote?
To determine the knob you should always keep the last accepted value not equal to 0xffffffff. If you receive the 0xffffffff, continue running the function of the last pressed knob.

Can you explain better? Or write a pseudocode (or better the code) for this

based on your code:

if (irrecv.decode(&results)){
  Serial.println(results.value);

  if (result.value != 0xffffffff)          // new knob pressed
   { command = result.value; 
     previous_command = command ;
   }
  else                                    // code = 0xffffffff, repeat the previous command
  { 
   command = previous_command;
   }

switch (command) {
  
   case 0x11223344:     // do something based on code value
  .....
}
 
irrecv.resume();
}
1 Like

Run a tutorial for the IR hardware selected to gain the knowlegde.

Thank you @b707 can i ask you a question?

of course

I created a topic around my question.
Please can i get your response

I answer in all topics where I have something to say :slight_smile:

Okayy ,
I want your help developing my skills in c and in handling embedded devices.

Can you help me with any resources??

Sorry, It is difficult for me to answer general questions because I do not speak English well

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.