Go Down

Topic: Troubleshooting Arduino Nano IR LED (Read 373 times) previous topic - next topic

pro-namel

Jun 13, 2019, 09:33 am Last Edit: Jun 13, 2019, 09:34 am by pro-namel
Hey guys, new to Arduinos and I just received my nano yesterday and been tinkering with it along with trying to set up an IR remote controlling individual LED's. I was wondering why this set up is not working. Any pointers on what I did wrong? Picture include, any help is greatly appreciated.

https://imgur.com/a/aG8lyLJ First time ever soldering so please excuse the mess.

Code: [Select]

#include <IRremote.h>
 
  const int RECV_PIN = 2;
  IRrecv irrecv(RECV_PIN);
  decode_results results;
  const int redPin = 10;
 
 
  void setup(){
    irrecv.enableIRIn();
    irrecv.blink13(true);
    pinMode(redPin, OUTPUT);
  }
 
  void loop(){
      if (irrecv.decode(&results)){
 
          switch(results.value){
            case 0x726A350A: //Keypad button "1"
            digitalWrite(redPin, HIGH);
            delay(500);
            digitalWrite(redPin, LOW);
            }
 
         
          irrecv.resume();
      }
  }


Grumpy_Mike

Check the IR LED is working. Look at it with the electronic view finder of a camera and you will see it blink, or not.

pro-namel

Check the IR LED is working. Look at it with the electronic view finder of a camera and you will see it blink, or not.
It seems to be working, I've tested it with the IR decoder while I point at the IR LED and codes are being put out on the serial monitor. I also tried multiple IR LEDS and it's still not working, do you think it could be the code or just faulty wiring?

PaulRB

Quote
I was wondering why this set up is not working. Any pointers on what I did wrong?
Well, you failed to describe what actually happens vs. what you expected to happen.

+1 karma for using code tags. Please attach images to your post on the forum, not on other image hosting sites, and when posting links, make them clickable, using the link icon, don't just cut & pasted addresses.

pro-namel

Well, you failed to describe what actually happens vs. what you expected to happen.

+1 karma for using code tags. Please attach images to your post on the forum, not on other image hosting sites, and when posting links, make them clickable, using the link icon, don't just cut & pasted addresses.
Will remember to attach images to the post next time, but I was expecting the red LED to blink when I pressed the IR remote. What actually happened was nothing, it just didn't work and I swapped multiple LEDs with no different outcome. I also forgot to mention I am very very new to this so any pointers would be greatly appreciated.

Grumpy_Mike

#5
Jun 13, 2019, 12:30 pm Last Edit: Jun 13, 2019, 12:32 pm by Grumpy_Mike
So all that proves is that you are not getting back 0x726A350A from the decode. Find out what you are getting back by addling a:-
Code: [Select]
Serial.println(results.value, hex);
just before the case statement.
you also need to add a
Code: [Select]
Serial.begin(9600);
in the setup function.

Open the serial monitor to see the results printed out.

pro-namel

So all that proves is that you are not getting back 0x726A350A from the decode. Find out what you are getting back by addling a:-
Code: [Select]
Serial.println(results.value, hex);
just before the case statement.
you also need to add a
Code: [Select]
Serial.begin(9600);
in the setup function.

Open the serial monitor to see the results printed out.

That is odd because the hex code I am getting back for the button no.1 is 726A350A. This is the code in the IRrec Demo decoder.

Code: [Select]


#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
 Serial.begin(9600);
 // In case the interrupt driver crashes on setup, give a clue
 // to the user what's going on.
 Serial.println("Enabling IRin");
 irrecv.enableIRIn(); // Start the receiver
 Serial.println("Enabled IRin");
}

void loop() {
 if (irrecv.decode(&results)) {
   Serial.println(results.value, HEX);
   irrecv.resume(); // Receive the next value
 }
 delay(100);
}

pro-namel

So all that proves is that you are not getting back 0x726A350A from the decode. Find out what you are getting back by addling a:-
Code: [Select]
Serial.println(results.value, hex);
just before the case statement.
you also need to add a
Code: [Select]
Serial.begin(9600);
in the setup function.

Open the serial monitor to see the results printed out.

Got it working, just a stupid mistake of plugging the resistor in the wrong slot.

Go Up