IR remote power button should turn LED on/off, blinks fast/flickers instead

*The original project comes from a website whose link I lost, though I intend to recover it for credit purposes. I do not own any part/did not partake in the making of the original project. I wholly give my credits to the original project maker.

Project background: Three different-color LEDs. IR remote. Temperature sensor. IR sensor. One LED lights up depending on the temperature (e.g. red for hot, yellow for somewhere in between hot and cold, and green for cold.) IR remote’s power button should turn whichever of the current LED is on/off to on/off.

Problem: Instead of the LED turning on/off, it blinks fast/flickers instead.

I consider myself new to the Arduino programming language and to Arduino itself and I admit I am confused and not sure whether I can work this out.

Here is the code:

#include <IRremote.h>
int RECV_PIN = 11;
int ledpin1 = 4;   //red
int ledpin2 = 3;   //green
int ledpin3 = 2;  //yellow 
boolean ledState = HIGH;
IRrecv irrecv(RECV_PIN);
decode_results results;

const int hot = 87; //set hot parameter
const int cold = 75; //set cold parameter
void setup() {
pinMode(A2, INPUT); //sensor
pinMode(2, OUTPUT); //blue
pinMode(3, OUTPUT); //green
pinMode(4, OUTPUT); //red
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(ledpin1,OUTPUT); 
pinMode(ledpin2,OUTPUT); 
pinMode(ledpin3,OUTPUT); 
}

/*if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);

/*if(results.value == 0xFD00FF){
ledState = !ledState;                                 
digitalWrite(ledPin,ledState);                     
}
irrecv.resume();
}*/

void loop() {

int sensor = analogRead(A2);
float voltage = (sensor / 1024.0) * 5.0;
float tempC = (voltage - .5) * 100;
float tempF = (tempC * 1.8) + 32;
Serial.print("temp: ");
Serial.print(tempF);
if (tempF < cold) { //cold
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
Serial.println(" It's Cold.");
}
else if (tempF >= hot) { //hot
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
Serial.println(" It's Hot.");
}
else if (tempF != hot || tempF !=cold) { //fine
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
Serial.println(" It's Fine.");
}
else (results.value == 0xFD00FF);

{  
  if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume();
}
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}

delay(10);
}

#IR
#include <IRremote.h>
int RECV_PIN = 11;
int ledPin = 10;                                                   // LED – digital 10
boolean ledState = LOW;                                 // ledState to store the state of LED
IRrecv irrecv(RECV_PIN);decode_results results;

void setup(){
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(ledPin,OUTPUT);                            // define LED as output signal
}

void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);

//once receive code from power button, the state of LED is changed from HIGH
//to LOW or from LOW to HIGH.

if(results.value == 0xFD00FF){
ledState = !ledState;                                    //reverse
digitalWrite(ledPin,ledState);                     //change the state of LED
}
irrecv.resume();
}
}

#2SENSE
const int hot = 87; //set hot parameter
const int cold = 75; //set cold parameter
void setup() {
pinMode(A2, INPUT); //sensor
pinMode(2, OUTPUT); //blue
pinMode(3, OUTPUT); //green
pinMode(4, OUTPUT); //red
Serial.begin(9600);
}
void loop() {
int sensor = analogRead(A2);
float voltage = (sensor / 1024.0) * 5.0;
float tempC = (voltage - .5) * 100;
float tempF = (tempC * 1.8) + 32;
Serial.print("temp: ");
Serial.print(tempF);
if (tempF < cold) { //cold
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
Serial.println(" It's Cold.");
}
else if (tempF >= hot) { //hot
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
Serial.println(" It's Hot.");
}
else { //fine
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
Serial.println(" It's Fine.");
}
delay(10);
}
else if (tempF != hot || tempF !=cold) { //fine

The if part of this statement is not needed. If it was, I suspect that you want && in there, not ||.

else (results.value == 0xFD00FF);

What is the purpose of that stuff in the parentheses? Why are there even parentheses there?

I find it hard to believe that the code you posted even compiles.

But, suppose that the problem was just that you posted the wrong thing. On every pass through loop(), you set the state of all 3 LEDs based on the temperature. Then, you try to use the remote to turn them on or off. As soon as loop() runs again, they will be turned on, or off, based on the temperature again.

I must admit that I do not understand what you are trying to accomplish.

Was the article this one?

Or this one?
https://create.arduino.cc/projecthub/luca-mcloughlin/arduino-led-temperature-indicator-6874d9?f=1

Anyway, you have a sketch that shows the temperature range with LEDs and a sketch that toggles a single LED on or off and you want to combine them. The IR sketch uses ‘ledState’ to keep track of if the LED is ON or OFF. Keep that and throw out the ledPin and digitalWrite() that control the LED. Put that part at the top of your sketch. Then use ‘ledState’ to control the rest of the temperature sketch.

Note: If you define meaningful names for your pin numbers AND USE THEM it makes the code easier to understand and avoids the need for many comments.

#include <IRremote.h>
const byte TEMPERATURE_SENSOR_PIN = A2;
const byte IR_RECV_PIN = 11;
const byte YELLOW_LED_PIN = 2;
const byte GREEN_LED_PIN = 3;
const byte RED_LED_PIN = 4;
boolean ledState = HIGH;


IRrecv irrecv(IR_RECV_PIN);
decode_results results;


const int hot = 87; //set hot parameter
const int cold = 75; //set cold parameter
void setup() {
  Serial.begin(9600);
  // Note: pinMode not needed for analog inputs
  pinMode(RED_LED_PIN, OUTPUT);
  pinMode(GREEN_LED_PIN, OUTPUT);
  pinMode(YELLOW_LED_PIN, OUTPUT);


  irrecv.enableIRIn();
}




void loop()
{
  if (irrecv.decode(&results))
  {
    Serial.println(results.value, HEX);
    if (results.value == 0xFD00FF)
    {
      ledState = !ledState;  //reverse
    }
    irrecv.resume();
  }


  if (ledState == false)
  {
    // Lights off
    digitalWrite(YELLOW_LED_PIN, LOW);
    digitalWrite(GREEN_LED_PIN, LOW);
    digitalWrite(RED_LED_PIN, LOW);
  }
  else
  {
    // Lights on, based on temperature
    int sensor = analogRead(TEMPERATURE_SENSOR_PIN);
    float voltage = (sensor / 1024.0) * 5.0;
    float tempC = (voltage - .5) * 100;
    float tempF = (tempC * 1.8) + 32;
    Serial.print("temp: ");
    Serial.print(tempF);


    if (tempF < cold)
    { //cold
      digitalWrite(YELLOW_LED_PIN, HIGH);
      digitalWrite(GREEN_LED_PIN, LOW);
      digitalWrite(RED_LED_PIN, LOW);
      Serial.println(" It's Cold.");
    }
    else 
    if (tempF >= hot)
    { //hot
      digitalWrite(YELLOW_LED_PIN, LOW);
      digitalWrite(GREEN_LED_PIN, LOW);
      digitalWrite(RED_LED_PIN, HIGH);
      Serial.println(" It's Hot.");
    }
    else
    { //fine
      digitalWrite(YELLOW_LED_PIN, LOW);
      digitalWrite(GREEN_LED_PIN, HIGH);
      digitalWrite(RED_LED_PIN, LOW);
      Serial.println(" It's Fine.");
    }
    delay(10);
  }
}