Unable to demonstrate digital output

My Arduino NANO sketch is really very simple and uses only one digital input and three digital outputs. I've been using only pins A0, A1, A2, and A3 and everything works. I wanted some experience using the digital pins, particularly to learn how to declare them, and breadboarded this simple sketch:

int MOJO = 12;
void setup() {
pinMode(MOJO, OUTPUT);
}
void loop() {
digitalWrite(MOJO, HIGH);
delay(1000);
digitalWrite(MOJO, LOW);
delay(1000);
}

It compiles and uploads OK. I hung a voltmeter on pin D9 to monitor voltage swings. No signal. I checked several other digital outputs on either side of D9, no signal. I modified the sketch and tried a half dozen different pins. No dice. I know I'm making some stupid mistake and I won't blame you if you're too disgusted to help.

Your code says pin 12.

Please remember to use code tags when posting code

That's part of the problem. I don't understand why the D pins have numbers too. Many tutorials talk about this pin and that pin, but I can't tell if they want to refer to one of them as "D9" or "12".

Why does this work:

void setup()  {
pinMode(A4, OUTPUT);

```but if I change A4 to D9 it won't compile  "D( was not declared in this scope"  ???

Because the Nano board configuration doesn't know anything about Dx pins?

Then why is EVERY Nano board marked with D0 through D12?

Try asking your question at Arduino.cc

We have also A0, A1, ..., A5 markings on the NANO Board. Why?

We need to know that:
The marks D0 - D13 marks refer to 0 (Digital Pin-0) - 13 (Digital Pin-13) respectively.
The A0 - A5 marks refer to 14 (Digital Pin-14) - 19 (Digital Pin-19) respectively.

The Arduino Compiler knows the meanings of the digital pins as --
0 - 7 for PD0 - PD7 (Port Pins of PORT D of the MCU)
8 - 13 for PB0 - PB5 (Port Pins of PORT B)
14 - 19 as PC0 - PC5 (Port Pins of PORT C)

The following diagram may be helpful:

D0 - D12 might stand for DPin-0 (Digital IO Pin number 0) to DPin-12.

Can somebody please tell me how to modify my sketch to blink an LED on one of the digital pins?

Do you want get modified your following sketch of Post-1?

int MOJO = 12;
void setup() {
pinMode(MOJO, OUTPUT);
}
void loop() {
digitalWrite(MOJO, HIGH);
delay(1000);
digitalWrite(MOJO, LOW);
delay(1000);
}`

Check that there is a LED (marked L) on the NANO Board. This Led-L is connected with D13-pin of the NANO Board.

From Post-8, we have learnt that D13 is actually digital pin number 13.

Now, we may modify your program as follows:

#define D13 13  //symbolic name D13 is mapped to digital pin 13

void setup() 
{
  pinMode(D13, OUTPUT);
}

void loop() 
{
  digitalWrite(D13, HIGH);
  delay(1000);
  digitalWrite(D13, LOW);
  delay(1000);
}

Upload the above sketch and check L is blinking at 1-sec interval.

Your modified sketch works well. But I'm confused. Nano's pin 13 is marked D10, not D13. D13 is pin 16.


NANO Pin Numbers

You're confusing the DIL (dual in-line) pin number with its Arduino functional pin.

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