[Solved]IR remote holding down a button

Hi guys!
My problem is basically that when i hold down a button on my remote it seems to not check for the signal again until i let go of it.That leaves me with 1 blink (im using leds just to test how this works)
instead of a continous blinking

Here’s the code:

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

#define resetb2 0xFF18E7
#define button1 0xFF30CF
#define button3 0xFF7A85


IRrecv irrec(11);
decode_results results; 

void setup() 
{ 
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  
  Serial.begin(9600);
  irrec.enableIRIn();  
} 

void loop() 
{ 
  if (irrec.decode(&results)){
      switch(results.value){
    
      case button1:
        digitalWrite(13, HIGH);
        delay(100);
        digitalWrite(13, LOW);
        delay(100);
        
      break;
    
      case button3:
        digitalWrite(12, HIGH);
        
      break;
  
      case resetb2:
        digitalWrite(12, LOW);
        digitalWrite(13, LOW);
        
      break;
  
      }
    irrec.resume();
    }


}

It is common for a special code to be sent when a key (any key) is held down. What code do you get when you hold down the key, if any ? If you get a continuous stream of the same code then you can detect it and make the Arduino do what you want.

What does your receiver receive while you have the button held down. Many remotes send a code that means 'repeat' while a button is held. There may be some buttons that DONT repeat. For example it would not be helpful for the power button to repeat. If that is the case you will have to pick a different button.

UKHeliBob:
It is common for a special code to be sent when a key (any key) is held down. What code do you get when you hold down the key, if any ? If you get a continuous stream of the same code then you can detect it and make the Arduino do what you want.

johnwasser:
What does your receiver receive while you have the button held down. Many remotes send a code that means 'repeat' while a button is held. There may be some buttons that DONT repeat. For example it would not be helpful for the power button to repeat. If that is the case you will have to pick a different button.

I know that holding down a button on some remotes cause it to change id to 0xFFFFFF but i tried with that too and that didn't do anything as well.And my remote is car mp3 which supposedly sends 0xFFFFFF when holding down.

i tried with that too and that didn't do anything

Did you try printing what you were receiving ?

Skarred:
I know that holding down a button on some remotes cause it to change id to 0xFFFFFF but i tried with that too and that didn't do anything as well.And my remote is car mp3 which supposedly sends 0xFFFFFF when holding down.

You should have opened with that....

UKHeliBob:
Did you try printing what you were receiving ?

Okay so i tried that and also figured out that it sends 0xFFFFFFFF when you hold it down(2 more f-s of course -.-)And it prints out dots and weird characters but it does repeat the blinking only problem is now that it repeats both leds not just one.

#include <SoftwareSerial.h>
#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

#define resetb2 0xFF18E7
#define button1 0xFF30CF
#define button3 0xFF7A85
#define hold 0xFFFFFFFF

int repeat = 0;
IRrecv irrec(11);
decode_results results; 

void setup() 
{ 
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  
  Serial.begin(9600);
  irrec.enableIRIn();  
} 

void loop() 
{ 
  if (irrec.decode(&results)){
    char res = results.value;
    Serial.print(res);
      switch(results.value){
    
      case button1:
        repeat = 1;
        
      break;
    
      case button3:
        repeat = 2;
        
      break;
  
      case hold:
        if(repeat = 1){
          digitalWrite(13, HIGH);
          delay(100);
          digitalWrite(13, LOW);
          delay(100);
        }
        if(repeat = 2){
          digitalWrite(12, HIGH);
          delay(100);
          digitalWrite(12, LOW);
          delay(100);
        }
      break;
  
      }
    irrec.resume();
    }


}
       if (repeat = 1)

Whoops !

UKHeliBob:

       if (repeat = 1)

Whoops !

i've put that there so it wouldn't be blinking both leds

case button1:
        repeat = 1;
       
      break;
   
      case button3:
        repeat = 2;
       
      break;

After pressing it it should change which one should be blinking if i hold it down shouldn't it?

i've put that there so it wouldn't be blinking both leds

Look closely at what the line of code is doing. Is it doing what you intend and checking the value of repeat ?

UKHeliBob:
Look closely at what the line of code is doing. Is it doing what you intend and checking the value of repeat ?

Damnit i always forget the double =. Thank you!!

You got there in the end.

You can get the compiler to throw an error if you use
if (1 = repeat)instead as it won't allow the attempt to assign a value to a constant but that form always seems odd to me.