Big issue breaking my brain, plz help!

So, what the code is suppose todo is read the ir hex after 2 seconds of setup(), and set yes to the returned value.

Then in loop check if a ir value has been received and ifso high a pin and low a pin.

But when i hit the button of my remote it will light up the led attached.
If i hit a different button it still lights up the led attached?
It for somewhat reason continiously setting yes to a new ir value.
I would love some guidance!

#include <IRremote.h>
const int toggle_pin = 2;
const int RECV_PIN = 1;

IRrecv irrecv(RECV_PIN);
decode_results results;  
 String yes = "";//button we want!
boolean set = true;

void setup()
{

  pinMode(toggle_pin,OUTPUT);
  pinMode(RECV_PIN,INPUT);
  irrecv.enableIRIn(); // Start the receiver
   
   delay(2000);
   if(set){
     if (irrecv.decode(&results)) {
            yes = String(results.value,HEX);
            set = false;
           irrecv.resume();
     }
    }
    digitalWrite(toggle_pin,HIGH);
   delay(250);
   digitalWrite(toggle_pin,LOW);
}



void loop() {
 
   if (irrecv.decode(&results)) {
      if(String(results.value,HEX) == yes){
         //AKA correct button pressed
         digitalWrite(toggle_pin,HIGH);
         delay(250);
         digitalWrite(toggle_pin,LOW);
       }
    irrecv.resume(); // Receive the next value
  }

  delay(250);
    
    
  

}

I would try printing those two Strings to serial monitor to see if there was maybe a clue there.

Your code attached the receiver to pin 1 which is used by the usb-serial.
I switch that in my code to 2 and moved the toggle to 3.

You can not compare Strings with ‘==’, but why convert the values to Strings anyway?

So I would suggest using an unsigned long for the remembered IR-code

#include <IRremote.h>
const int toggle_pin = 3;
const int RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long wantedCode;
boolean set = true;

void setup()
{
  pinMode(toggle_pin, OUTPUT);
  pinMode(RECV_PIN, INPUT);
  irrecv.enableIRIn(); // Start the receiver

  delay(2000);
  if (set) {
    if (irrecv.decode(&results)) {
      wantedCode = results.value;
      set = false;
      irrecv.resume();
    }
  }
  digitalWrite(toggle_pin, HIGH);
  delay(250);
  digitalWrite(toggle_pin, LOW);
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == wantedCode) {
      digitalWrite(toggle_pin, HIGH);
      delay(250);
      digitalWrite(toggle_pin, LOW);
    }
    irrecv.resume(); // Receive the next value
  }
}

So, i might of should have been more clear. So this was on a ATtiny and i have tried it without the yes check, it worked!. I used an actual arduino to check the IR value from my remote but the ir library for attiny is different from the normal arduino and i think the values are different from each other even while using a long value.

Whandall: You can not compare Strings with '=='..."

Of course you can! The String object supports the == operator.

Regards, Ray L.

Lawhit: i think the values are different from each other even while using a long value.

results.value is of type unsigned long, I would leave the codes in that representation. The received values should not depend on the library/platform.

Use the output pin LED to display the received value in binary for debugging, or use software serial and hook up a monitor.

/*
 * 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>
const int toggle_pin = 2;
const int RECV_PIN = 1;

IRrecv irrecv(RECV_PIN);
decode_results results;  
 unsigned long yes = 0;//button we want!


void setup()
{

  pinMode(toggle_pin,OUTPUT);
  pinMode(RECV_PIN,INPUT);
  irrecv.enableIRIn(); // Start the receiver
   
  
    digitalWrite(toggle_pin,HIGH);
   delay(250);
   digitalWrite(toggle_pin,LOW);
}



void loop() {
   

   if (irrecv.decode(&results)) {
     if(yes == 0){
         yes = results.value;
         //aka set new value!
         digitalWrite(toggle_pin,HIGH);
         delay(100);
         digitalWrite(toggle_pin,LOW);
         delay(100);
         digitalWrite(toggle_pin,HIGH);
         delay(100);
         digitalWrite(toggle_pin,LOW);
     }else if(results.value == yes){
         //AKA correct button pressed
         digitalWrite(toggle_pin,HIGH);
         delay(250);
         digitalWrite(toggle_pin,LOW);
       }
    irrecv.resume(); // Receive the next value
  }

  delay(250);
    
    
  

}

So this will constantly set the value even tho yes is no longer 0? IDK why its doing this…
It constantly runs the on/off-on/off instead of it running once and from there on only run the on/off

Apperently, the ir library returns 0 to all values except NEC repeat. I really dont know what todo anymore...I have tried 2 different attinies too but no result.