digitalWrite pin names/numbers on Arduino Micro

I've been trying to toggle a pin on my Arduino Micro ... and I'm having trouble figuring out what pin names to use.

The AtMega datasheet (http://www.atmel.com/images/7766s.pdf) gives the pinout of the chip.

The Micro circuit diagram(http://arduino.cc/en/uploads/Main/arduino-micro-schematic.pdf) shows how the AtMega chip is connected to the headers on the Micro. This(http://arduino.cc/en/Main/arduinoBoardMicro) show the names on each pin of the headers.

So...

In my sketch I try to toggle Arduino Micro pin D8:

#define CHIP_PIN_28 28
#define PB4 CHIP_PIN_28
#define MICRO_D8 PB4

void setup() {

pinMode(MICRO_D8, OUTPUT);

delay(500);

}

void loop() {
digitalWrite(MICRO_D8, HIGH);
delay(100);
digitalWrite(MICRO_D8, LOW);
delay(100);
}

When I hook my scope to "D8", I see nothing.

So my question is when I do a digitalWrite(<pin#>, HIGH)
what do I use for pin#??? I'm really confused about what value to use?

Thanks in advance for any help you may provide

Hi slowjourney

To work with digital pin 8 (i.e. the one marked D8 on the PCB next to the pin), remove these from your code:

#define CHIP_PIN_28    28
#define PB4    CHIP_PIN_28
#define MICRO_D8     PB4

... and just do this:

pinMode(8, OUTPUT);
digitalWrite(8, HIGH);

Regards

Ray

digitalWrite(), digitalRead(), and pinMode() use the Arduino pin numbers or, for the Analog Input pins that can double as digital I/O pins, the analog input pin name:

digitalWrite(2, HIGH);
...
digitalWrite(13, HIGH);
digitalWrite(A0, HIGH);
...
digitalWrite(A5, HIGH);

A0-A5 have digital pin numbers, too, but they are different for different models of Arduino. On the UNO they are called 14 through 19 but on the MEGA they are up in the 50's and on the Leonardo they start somewhere around 18. Best to use the names (A0-A5) so your sketch works on other models of Arduino.

analogRead() can use the names (A0-A5) or the analog pin numbers (0-5).

The bar at the top of the forum page has links, Home Buy Download Products Learning, etc.

Click on Products then find your board and click that. Somewhere in that page you should find a link to a pin map for the chip and board that will let you map between the two.

As you get more into Arduino, surf the site itself and bookmark sections to make easy lookup later.

These are just some I use a lot.

http://www.nongnu.org/avr-libc/user-manual/modules.html

http://playground.arduino.cc/Main/GeneralCodeLibrary

The site is the manual. RTFM!

slowjourney:
... and I'm having trouble figuring out what pin names to use.

Me too!!! Even on this date 24 May 2020!!

I have been hunting the various Arduino Micro documentation and reference sites and was not able to find this info until I found this forum thread. This info SHOULD BE at an easy to find spot.

Perhaps on the hardware pin diagram page, PLEASE (for all Arduino models).

arwit:
Me too!!! Even on this date 24 May 2020!!

I have been hunting the various Arduino Micro documentation and reference sites and was not able to find this info until I found this forum thread. This info SHOULD BE at an easy to find spot.

Perhaps on the hardware pin diagram page, PLEASE (for all Arduino models).

What is the question? If you're complaining about a lack of pin diagrams, you're mistaken, they are available on site.

Which Arduino?

Try searching arduino pin map and pick which one.

Atmega48/88/168 and 328 all share the same pin map. AVR's come in such lines, the amount of memory changes.

So when you click on pin map for Uno and it shows you a 168, don't get bent out of shape, they're the same. They can all be used on an Uno 3.

The map is chip pins to board pins, hence pin map.