IR receiver won't work with nano

Hello,

New hobbyist here, just getting started. I'm hoping I can get some advice for the annoying problem I'm facing.

Has anyone here managed to get an Arduino nano to work with an IR receiver? Please share how you went about it.

Objective: To verify that I can get an IR receiver (TSOP1738) connected to the Nano to decode signals from an IR remote.

Problem: The serial monitor on the Arduino IDE does not show any hex codes. I've been eliminating possibilities with different tests and am now almost at the end. Would appreciate help on potential fixes.

Possibility 1: Maybe the IR receiver is faulty
Test : tried changing the receiver. Tried 6 so far and none work. So I don't think it's the receiver.

Possibility 2: Maybe the IR remote is unique in its frequency output (either different from the usual 38khz or some outlier protocol that the receiver can't decode).
Test: tried several remotes, 5 of them. Ensured some of them were basic old ones just to be sure there wasn't some proprietary protocol in play. So that's not it either.

Possibility 3: Maybe the digital pin on the Arduino nano is faulty
Test: tried multiple digital PWM pins. No luck.

Possibility 4: Maybe the Arduino is faulty
Test: ran the blink led sample code and confirmed that the Arduino works.

Possibility 5: Maybe the circuit components or connections are faulty
Test: All connections seem to be wired fine. I'm using the Arduino 5v and Gnd pin to power the IR receiver. Multimeter shows receiver is getting 4.59v which I assume is sufficient. Using a 330 ohm resistor between Arduino digital pin and TSOP signal pin.

The library I'm using is the 'IRremote.h' . Sketch is the example one called 'IRRecvDemo', I've made a few minor modifications.

If anyone would like to examine my code, here it is:

#include <IRremote.h>

int RECV_PIN = 16;

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(500);
}

I've deleted your other cross-post @samuraijack256.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Why are you using PIN 16?
Try PIN 11 that is in the IDE example.

Have you looked here?

https://create.arduino.cc/projecthub/electropeak/use-an-ir-remote-transmitter-and-receiver-with-arduino-1e6bc8?f=1

Tom... :slight_smile:

I tried pin 11 (D8) but it didn't work either. I'm attaching my circuit diagram.

  1. You don't need a PWM pin
  2. Pin D8 is known to the IDE as pin 8. That's the number you need to use NOT the AVR pin numbers.

Steve

Hi,
OPs diagram.

Thanks.. Tom.. :slight_smile:

slipstick:

  1. You don't need a PWM pin
  2. Pin D8 is known to the IDE as pin 8. That's the number you need to use NOT the AVR pin numbers.

Steve

Thank you! this is what I was missing. I assumed the IDE understood the PIN numbers by the physical pin starting from the top left.

so Pin D8 should be referenced in my code as 8.

While we're on this topic, can someone help me understand the PIN naming (according to IDE) for the other pins? For instance if D7 is known as 7, what about A7? Every time I google this question, I only get PIN out diagrams that don't directly answer my question. Maybe I'm using the wrong phrase.

Hi,

pinMode(A7,INPUT);
pinMode(A6, OUTPUT);

works.
A6 and A7 do not have internal pullups.

Tom.. :slight_smile:

Nor do they have output or digital input functions. :astonished:

Paul__B:
Nor do they have output or digital input functions. :astonished:

DOHHHH.. sorry you are right... :o :o :o

samuraijack256:
While we're on this topic, can someone help me understand the PIN naming (according to IDE) for the other pins? For instance if D7 is known as 7, what about A7? Every time I google this question, I only get PIN out diagrams that don't directly answer my question. Maybe I'm using the wrong phrase.

Always use the An pin names for the analog Arduino pins. For example:

reading = analogRead(A1);
pinMode(A1, INPUT_PULLUP);
digitalWrite(A1, HIGH);

Yes, they do have integer pin numbers, but why would you try to keep track of those when you could use the pin names that are marked on the board instead?

Yes, you can use the channel number with analogRead(), but you can't do that with any of the other functions, so it's bound to cause confusion eventually.

Yes, it's inconsistent that we use the An pin names for the analog pins, but not Dn pin names for the digital pins, especially on the boards that have Dn pin names marked on the board, but that system was set up long ago so we just have to accept it.