Issue with infrared based circuit

Hey Everyone,

I need some help with my project. All I need to do is have one Arduino Uno transmit an IR signal and then another Arduino Uno receive that code and then cause an LED to turn on for 2 seconds. (my full project is much much larger but this is the part that I'm having an issue with.)

My IR transmitter circuit transmits the correct NEC value that I want it to because the LED lights up. The issue is that the light keeps blinking even when nothing is being transmitted. This is very perplexing to me because when I use Sparkfun's IR Remote: shttps://www.sparkfun.com/products/11759 from the IR Control Kit: https://www.sparkfun.com/products/11761, the LED turns on for 2 seconds and then turns off like it is supposed to.

Here is my code for the IR Transmitter. It is essentially straight from the sparkfun code but tweaked to work to my needs:

#include <IRremote.h> // Include the IRremote library

IRsend irsend; // Enables IR transmit on pin 3

const int buttonPin = 12; // Button pin. Pulled up. Triggered when connected to ground.

// setup() initializes serial and the Infrared receiver.
void setup()
{
  Serial.begin(9600);

  pinMode(buttonPin, INPUT_PULLUP);
}

// loop() checks for either a button press or a received IR code.
void loop()
{
  // If the button is pressed, and we've received a code...
  if (digitalRead(buttonPin) == LOW)
  {
    sendCode(); // Sends out our code. (See bottom of sketch).
    delay(1000);
  }
}


void sendCode()
{
    irsend.sendNEC(0x10EFD827, 32);
    Serial.println("Sent NEC Power");
 
}

Here is my code for the IR Receiver:

#include <IRremote.h>

int IRpin = 11;  // pin for the IR sensor
int LEDb = 12;    // blue LED pin 
int LEDg = 8;    // green LED pin 
IRrecv irrecv(IRpin);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(LEDb, OUTPUT);
  pinMode(LEDg, OUTPUT);
}

void loop() 
{
   
  if (irrecv.decode(&results)) 
    {
      
      irrecv.resume();   // Receive the next value
    }
  
  
  
   if (results.value == 0x10EFD827)  // NEC value to be recieved (Power Button)
     {  
           
           digitalWrite(LEDb, HIGH);
           delay(2000);      // wait 1 second
           digitalWrite(LEDb, LOW);
           delay(100);      // keeps the transistion smooth
     }
   if (results.value == 0x10EFF807)  // NEC value to be recieved (A Button)
     {  
           digitalWrite(LEDg, HIGH);
           delay(2000);      // wait 1 second
           digitalWrite(LEDg, LOW);
           delay(100);      // keeps the transistion smooth 
     }
     
     else
     { 
    Serial.println("done");
     }

}

Any help would be greatly appreciated!

Try clearing results.value in the if statement after the led blink.

It is a bad idea to have comments that do not match the code. How do you know which one is wrong?

I tried changing the results.value to some random signal (0xFFFFFFFF) in the if statement after the led blink. This did not fix my problem. Is there a way to somehow "trick" the arduino into thinking it has received a signal through the IR Receiver without actually anything being sent from the transmitter circuit?

I don't believe my issue is the receiver. It is most probably has to do with how I am transmitting the IR. I believe this to be the case because, as I stated earlier, the receiver works perfectly when I use spark fun's IR remote: shttps://www.sparkfun.com/products/11759.

As for the comments; I think there were some leftover comments from me stripping the program down to its bare minimums but now there shouldn't be anything extra. Sorry for the confusion.

Here is my most recent code for the transmitter:

#include <IRremote.h> // Include the IRremote library

IRsend irsend; // Enables IR transmit on pin 3

const int buttonPin = 12; // Button pin. Pulled up. Triggered when connected to ground.

// setup() initializes serial
void setup()
{
  Serial.begin(9600);

  pinMode(buttonPin, INPUT_PULLUP);
}

// loop() checks for a button press
void loop()
{
  // If the button is pressed...
  if (digitalRead(buttonPin) == LOW)
  {
    sendCode(); // Sends out our code. (See bottom of sketch).
  }
}


void sendCode()
{
    irsend.sendNEC(0x10EFD827, 32);
    Serial.println("Sent NEC Power");
    delay(3000);
 
}

And here is my most recent code for the Receiver:

#include <IRremote.h>

int IRpin = 11;  // pin for the IR sensor
int LEDb = 12;    // blue LED pin 
int LEDg = 8;    // green LED pin 
IRrecv irrecv(IRpin);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();    // Start the receiver
  pinMode(LEDb, OUTPUT);
  pinMode(LEDg, OUTPUT);
}

void loop() 
{
   
  if (irrecv.decode(&results)) 
    {
      
      irrecv.resume();   // Receive the next value
    }
  
  
  
   if (results.value == 0x10EFD827)  // NEC value to be recieved (Power Button)
     {  
           
           delay(100);
           digitalWrite(LEDb, HIGH);
           delay(2000);      // wait 1 second
           digitalWrite(LEDb, LOW);
           delay(100);      // keeps the transistion smooth

     }
   if (results.value == 0x10EFF807)  // NEC value to be recieved (A Button)
     {  
           digitalWrite(LEDg, HIGH);
           delay(2000);      // wait 1 second
           digitalWrite(LEDg, LOW);
           delay(100);      // keeps the transistion smooth 
     }
     
     results.value == 0;


}

I tried changing the results.value to some random signal (0xFFFFFFFF) in the if statement after the led blink. This did not fix my problem.

Try printing it out before and after you attempt to change it to see if it changes. It sounds like you are not changing it.
Look in the libary to see if you can find how to reset it, it could be another function.