Problem using Mega 2560 and the mini versionsence between Uno and Mega 2560

I have had a problem more than once; on Youtube.com, for example McWharter's lesson 22, on using the Arduino UNO with a Adafruit GPS. When I follow through using a HERO (which I think is a UNO clone), It works and I can run his program. But I am trying to use a MEGA 2560 Pro, or even a Mega 2560. And I have not been able to make those demo projects work.
Sometimes, these demos say to use pins 2 and 3 for something; but I have A2 and A3, and also D2 and D3. I can usually figure out which ones they mean, but the program still doesn't work. I thought I was upgrading, but I should go back to the simplest version?

When we refer to a pin by a number alone, we always mean the digital pin name. We always use the "A" prefix when referring to the analog pin names.

As for the "D" prefix, you will sometimes see people use this convention, and some Arduino boards have it on the pin labels. This can be a bit confusing because when someone says "A2", then you can use A2 in your code, for example:

Serial.println(analogRead(A2));

but usually you can't do the same with the digital pins when someone refers to them with the "D" prefix:

Serial.println(digitalRead(D2));

To make matters more confusing, on a few 3rd party boards, you can use the "Dn" style of pin names in your code. But it sounds like you aren't using any of those boards, so you don't need to worry about that.

We can likely help you out with that, but only if you provide enough information. We need your exact code, circuit, and a detailed description of what you mean by "doesn't work".

Does the GPS use software serial? For the Mega, change from software serial to use Serial1 instead.

If you want better help, read the forum guidelines and post your code in code tags.

I managed to find the code he is referring to, and it does use software serial, so the problem is caused by the limitations of software serial:

There is no reason to use software serial on a Mega with its 3 extra hardware serial ports.

@donerickson, your topic had been moved to a more suitable location on the forum.

Introductory tutorials is not for questions but to post tutorials :wink:

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