IR code works on UNO not Nano; many segmentation tests performed. Help please.

itsjustme:
I did nto say i was using D2 or D7. I said Pin 2 and Pin 7. Specifically "RX" or "D4" but I also tested others. It is connected to D4 in the pic.

Ok, the confusing part is that the sample codes you posted in the original post happen to be using D2 and D7 for the IR receiver pins, not the physical connector pins 2 and 7 on a Nano.

6v6gt:
That is where you are wrong. Pin 7 in your sketch is marked D7 in white on the silkscreen of the Nano.
It is NOT an integrated circuit type numbering system.

No, Pin 10 is D7 in the Nano documentation, and the 7th pin, counting from #1, is D4. I am looking at the documentation right now.
https://www.elprocus.com/an-overview-of-arduino-nano-board/

Show us at least the portion of your sketch that declares the IR receiver pin, to clear up any confusion.

Also, do not use D0 or D1 if you are also using Serial, that will cause a conflict.

david_2018:
Are you sure you are connecting to input pin 2 or pin 7? The nano had a ground and reset between the RX/TX pins (D1 and D0) and D2.

In your picture you are connected to input pin 4 (D4)

This diagram proves my point. 7th pin up, right side = pin 7. Labeled D4. My diagram has actual pin numbers - also confirmed in any footprints for CAD.

itsjustme:
No, Pin 10 is D7 in the Nano documentation, and the 7th pin, counting from #1, is D4. I am looking at the documentation right now.
Arduino Nano Board: Features, Pinout, Differences and Its Applications

I see why you are having such difficulty. Why not write a simply sketch which lights a led attached to that pin 7 and see for your self how far you get with your own personal idea of how the pins should be numbered. You said in your OP that you are new to this. You appear to want to contradict people who have considerable experience with this. The numbering is arbitrary and does not correspond with an integrated circuit type numbering system.

itsjustme:
This diagram proves my point. 7th pin up, right side = pin 7. Labeled D4. My diagram has actual pin numbers - also confirmed in any footprints for CAD.

And in the sketch you refer to that pin as 4, correct?

If you want to read the pin marked in red below, you do it so:

bool x = digitalRead( 7 ) ;

david_2018:
Show us at least the portion of your sketch that declares the IR receiver pin, to clear up any confusion.

Also, do not use D0 or D1 if you are also using Serial, that will cause a conflict.

Hi - both of my entire sketches are in my original post at the top.
Note they are not "MY" sketches as i pointed out - they are the demo code from the two libraries i am considering.
Now, can you elaborate on using D0, D1? The reason is that the library author chose D0 (pin 2). Not me. The library author.

I am using proven code before i introduce the uncertainty of my own sketch since I KNOW that may have issues early on.

I really appreciate all the enthusiastic help, but as this moves away form the original post we seem to be missing the basic point and be unaware of all the testing already done. Both work with my UNO. Sketches operate with my Nano until they require input. Then they become "mostly" inoperable. But note mostly - sometimes on a whim, they work, which means the pin MUST be right. Data does not jump from pin to pin through the air.

I am really confused on the topic of pins#s vs labels. There are in fact IC type pin numbers, and they are embedded in libraries for CAD. I am using those references. It is also what seems to be implied by documentation. Since analog, digital and the two GPIO pins can be used as digital pins, i infer that we cannot use the "DX" or "AX" assignments but must use actual pin numbers and then declare them properly.

But if I am wrong, this is absolutely my issue.

I am surprised (no mystified) that i ever get input if the wires are connected to the wrong pins.

For clarity; YES i am doing precisely what you point out. I declare the receive pin to be Pin 7, and then connect to D4 (which is in the tech documentation in fact Pin 7).

I will in fact take (someone') advice and connect an LED to it and clear this up.

6v6gt:
If you want to read the pin marked in red below, you do it so:

bool x = digitalRead( 7 ) ;

OK, so how int he world then, do i distinguish between using pin D7 and A7, both possible since digital is a subset of analog, since i see no "D" in your statement? I'm suspecting you are right and that this is a major misunderstanding on my part, but it seems needlessly vague when we have nice, stable, pin #s.
I'll test. This my be a Eureka moment.

Eureka!

First thanks to all staying with me.

Changing the wire to Pin 10 (D7) it works perfectly.

I now know that i cannot actually use pin numbers but must use functional labels.

This begs another question: where can i get really precise info on how to refer to labels/pins. Assuming that a digital read is on a digital pin is sometimes true, but need not be. So how is this resolved?

A pointer to specific tech documentation is all i need. Explanations are of course appreciated, but no need to waste any of your collective time, unless you wish to.

One very specific one since i have a very complex evaluation board made, into which this is a small piece of the jigsaw puzzle. How do i specifically refer to Pin #2 / RX to use it to read the IR reciever codes?

Thanks again,

G

I'm glad that is sorted out at last.

Yes it is confusing. This may go some way to answering your question about the pin numbering (of the Nano):

You'll have to "view" the image in your browser for it to be a readable size.

The purple numbers [unfortunately missing from the key] are the ones you use for digitalRead() etc. The deep green ones for analogRead().

6v6gt:
I'm glad that is sorted out at last.

Yes it is confusing. This may go some way to answering your question about the pin numbering (of the Nano):

https://components101.com/sites/default/files/component_pin/Arduino-Nano-Pinout.png

You'll have to "view" the image in your browser for it to be a readable size.

The purple numbers [unfortunately missing from the key] are the ones you use for digitalRead() etc. The deep green ones for analogRead().

Super helpful, now with the added context.
So to answer my own question, to read on RX i refer to it as "0" - (zero) right?

"How do i specifically refer to Pin #2 / RX"

Reading it as digital pin? 
byteX = digitalRead(0);

Reading it as serial data stream?
if (Serial.available() >0){
byteX = Serial.Read();
}

Reading A7?
intX = analogRead(A7); // A6, A7, do support digitalRead() (chip limitation)

Forget the numbers in parenthesis in the diagram. They are just physical pointers to where the pins are located mechanically, nothing else. They have nothing to do with programming. Nothing.

itsjustme:
Super helpful, now with the added context.
So to answer my own question, to read on RX i refer to it as "0" - (zero) right?

Yes, but only if you want to read it as a digital input pin (which is unusual).

However, if you want to read serial input, you do something like described here:

On the Nano (and Uno), the Serial port refers to pins 0 and 1 (RX / TX). Usually, you don't use these pins because they interfere with use of the serial monitor which prevents effective debugging.

Edit

post crossed with @CrossRoads

"digital is a subset of analog"
All pins are digital pins first. Everything else is secondary.

All pins are digital pins (except A6, A7).
The analog pins feed into the analog multiplexer.

Other pins connect to other functions on the digital pins: I2C, SPI, Serial, timers, counters, etc.

Thanks. The diagram posted by 6v6GT explained it, once i realized that Arduino does not use actual pin #s for programming.

I'm still stunned since it adds complexity and ambiguity. But it is what it is.

Actually, all i need to know is the numerical reference - the libraries i plan to use provide that part of the code. The rest is digitalWrite or analogWrite, and for those i also have the numbers.

The key thing to ensure i read the diagram correctly is that for reading, physical Pin #2 is #0 for digital reads (purple number). The diagram is not as clear for analog. Presume since no other pins do what Analog pins do, its simply inferred from the analogWrite or Read commands and is A0-7.

G

The analog pins add a bit of additional confusion. The best way to refer to them in code is by using the Ax notation, on an UNO A0 through A5. They can also be referred to with their digital pin numbers as shown in the diagram 6v6gt posted, but that makes the code less portable because those numbers will vary among arduino boards using different processors, while the Ax numbers are defined in the pins_arduino.h file for each specific board.

What can get really confusing is that analogRead() will accept either the Ax notation, or just a number, and will assume that you are referring to an analog pin since analogRead() only works on analog pins, while a digitalRead(), digitalWrite(), or pinMode() instruction will take that same number and assume it is referring to a digital pin, so requires the Ax notation. As an example, analogRead(1) and analogRead(A1) are functionally identical, while digitalRead(1) refers to digital pin D1 and digitalRead(A1) refers to analog pin A1.

The numbering is, in its nature, arbitrary.
The Arduino platform has its abstraction layer which attempts to shield users from the complexity of IC package in numbers, board pin numbers, port numbers etc. etc. You've simply got to find a decent diagram. You hardly ever refer to board pins (unless you are say designing a PCB which incorporates a Nano)
So, once that is understood, it should be eady to move between Arduinos. If the sketch refers to pin A4, you simply have to find A4 on the silk screen of the Arduino board.

Edit
Crossed with @david_2018

6v6gt:
Yes, but only if you want to read it as a digital input pin (which is unusual).

However, if you want to read serial input, you do something like described here:

Serial.read() - Arduino Reference

On the Nano (and Uno), the Serial port refers to pins 0 and 1 (RX / TX). Usually, you don't use these pins because they interfere with use of the serial monitor which prevents effective debugging.

Edit

post crossed with @CrossRoads

I don't have to use DO/Pin2 generally, but, as i noted earlier, this Nano is (will shortly be) an embedded system in a much larger solution, for which the evaluation boards (proto and early test) already exist. They connect IR receiver signal to D0/Pin 2. When in the board there is no serial connection to a monitor - its deep in a box. Outside the box, i can reassign it to anything. In the future i can reassign it to anything.

6v6gt:
The Arduino platform has its abstraction layer which attempts to shield users from the complexity of IC package.

You hardly ever refer to board pins (unless you are say designing a PCB which incorporates a Nano)

Crossed with @david_2018

Spot on. I thought about it and decided the authors wanted to allow code to run on UNOs, Nanos, Megas, Tinys even if the physical pins changed (within the overlap of course)/

And guilty! I came at this from designing a PCB with many chips and functions, and an Arduino as a simple way to add control. So i broke out the tech docs, and the CAD libraries (in both the physical pins are the last word) and proceeded. Only to get ambushed :slight_smile: