Leonardo and infrared

I'm trying to put together a specialized tv remote using an Arduino Leonardo, my project requires HID capabilities hence the Leonardo. At the moment I'm trying to figure out the signals I am going to be sending to the tv so I have an IR receiver.
The receiver is in a breadboard,
ground -> A1
VCC in A3
output in A5.
From the breadboard I have jumpers going
B1 -> Leo. ground
B3 -> Leo. 5v
B5 -> Leo. 13

Then I have the following sketch. When I shoot a tv remote into the receiver, nothing gets displayed in the serial monitor. Does anyone have any ideas what I'm doing wrong? I know every tutorial I see uses an Arduino Uno, is that the problem? Can the Leonardo can't do this?

// Include IR Remote Library by Ken Shirriff
#include <IRremote.h>

// Define sensor pin
const int RECV_PIN = 13;

// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
  // Serial Monitor @ 9600 baud
  Serial.begin(9600);
  // Enable the IR Receiver
  irrecv.enableIRIn();
}

void loop(){
  if (irrecv.decode(&results)){
        Serial.println(results.value, HEX);
        switch (results.decode_type){
            case NEC: 
              Serial.println("NEC"); 
              break;
            case SONY: 
              Serial.println("SONY"); 
              break;
            case RC5: 
              Serial.println("RC5"); 
              break;
            case RC6: 
              Serial.println("RC6"); 
              break;
            case DISH: 
              Serial.println("DISH"); 
              break;
            case SHARP: 
              Serial.println("SHARP"); 
              break;
            case JVC: 
              Serial.println("JVC"); 
              break;
            /*case SANYO: 
              Serial.println("SANYO"); 
              break;
            case MITSUBISHI: 
              Serial.println("MITSUBISHI"); 
              break;*/
            case SAMSUNG: 
              Serial.println("SAMSUNG"); 
              break;
            case LG: 
              Serial.println("LG"); 
              break;
            case WHYNTER: 
              Serial.println("WHYNTER"); 
              break;
            /*case AIWA_RC_T501: 
              Serial.println("AIWA_RC_T501"); 
              break;*/
            case PANASONIC: 
              Serial.println("PANASONIC"); 
              break;
            case DENON: 
              Serial.println("DENON"); 
              break;
          default:
            case UNKNOWN: 
              Serial.println("UNKNOWN"); 
              break;
          }
        irrecv.resume();
 }
}

Try a pin other than 13.

#include <IRremote.h>

// Define sensor pin
const int RECV_PIN = 12;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  while(!Serial);
  Serial.print"OK OK \r\n\r\n";
  irrecv.enableIRIn();
}

I did try pin 4 at first and had the same result.

Did you change the declarations and setup() as I posted?

I did and all I get in the serial monitor is "OK OK"

So it's clear that Serial Monitor is working.
I suppose your remote corresponds to one of those listed?

Do you mean in the switch cases? I don't know, That's one thing I'm trying to figure out. Even if it isn't, wouldn't I still see the signal via the results.value?

There are CASEs for several and an UNKNOWN.

What if you make an addition to loop ()
so you can see if anything made it in --

void loop()
{
  if (irrecv.decode(&results))
  {
    Serial.println("Got something");   // Anything at all??
    Serial.println(results.value, HEX);

Tried and nothing showed up.

Tried a LED+resistor on the IRreceiver's output to see if it's working?
Try that between Out and Gnd?

When I place the LED+resistor between Out and Gnd, it's On and blinks Off a little with a remote pushbutton active.
When placed between +5 and Out, it's Off and blinks On with a remote pushbutton active.
With that you can make a determination as to whether your remote and the Rcvr are compatible and operating.

I rigged this up with an ESP32 - and it worked.
I don't see the Leonardo (or any peculiarities) as a Blocker.
What IR receiver are you using (is it a 3-pin unit) ?

Just try the ReciveDemo example :slight_smile:

Thank you both of you! I finally figured out that the diagram included in the package had the signal pin and the VCC pin flipped. I didn't think getting the receiver to work was suppose to be difficult, looks like I was right, just had the wrong information.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.