Skip to Content
Arduino Cookbook, 2nd Edition
book

Arduino Cookbook, 2nd Edition

by Michael Margolis
December 2011
Intermediate to advanced
724 pages
16h 19m
English
O'Reilly Media, Inc.
Content preview from Arduino Cookbook, 2nd Edition

Appendix F. Digital and Analog Pins

Tables F-1 and F-2 show the digital and analog pins for a standard Arduino board and the Mega board.

The “Port” column lists the physical port used for the pin—see Recipe 18.11 for information on how to set a pin by writing directly to a port. The introduction to Chapter 18 contains more details on timer usage. The table shows:

  • USART RX is hardware serial receive

  • USART TX is hardware serial transmit

  • Ext Int is external interrupt (followed by the interrupt number)

  • PWM TnA/B is the Pulse Width Modulation (analogWrite) output on timer n

  • MISO, MOSI, SCK and SS are SPI control signals

  • SDA and SCL are I2C control signals

Table F-1. Analog and digital pin assignments common to popular Arduino boards

Digital pin

Arduino 168/328

Arduino Mega (pins 0–19)

Port

Analog pin

Usage

Port

Analog pin

Usage

0

PD 0

 

USART RX

PE 0

 

USART0 RX, Pin Int 8

1

PD 1

 

USART TX

PE 1

 

USART0 TX

2

PD 2

 

Ext Int 0

PE 4

 

PWM T3B, INT4

3

PD 3

 

PWM T2B, Ext Int 1

PE 5

 

PWM T3C, INT5

4

PD 4

  

PG 5

 

PWM T0B

5

PD 5

 

PWM T0B

PE 3

 

PWM T3A

6

PD 6

 

PWM T0A

PH 3

 

PWM T4A

7

PD 7

  

PH 4

 

PWM T4B

8

PB 0

 

Input capture

PH 5

 

PWM T4C

9

PB 1

 

PWM T1A

PH 6

 

PWM T2B

10

PB 2

 

PWM T1B, SS

PB 4

 

PWM T2A, Pin Int 4

11

PB 3

 

PWM T2A, MOSI

PB 5

 

PWM T1A, Pin Int 5

12

PB 4

 

SPI MISO

PB 6

 

PWM T1B, Pin Int 6

13

PB 5

 

SPI SCK

PB 7

 

PWM T0A, Pin Int 7

14

PC 0

0

 

PJ 1

 

USART3 TX, Pin Int 10

15

PC 1

1

 

PJ 0

 

USART3 RX, Pin Int 9

16

PC 2

2

 

PH 1

 

USART2 TX

17

PC 3

3

 

PH 0

 

USART2 RX

18

PC 4

4

I2C SDA

PD 3

 

USART1 TX, Ext Int 3

19

PC 5

5

I2C SCL

PD 2

 

USART1 RX, Ext Int 2

Table F-2. Assignments for additional Mega pins

Arduino ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Arduino Cookbook, 3rd Edition

Arduino Cookbook, 3rd Edition

Michael Margolis, Brian Jepson, Nicholas Robert Weldin
Arduino Cookbook

Arduino Cookbook

Michael Margolis
Getting Started with Arduino, 3rd Edition

Getting Started with Arduino, 3rd Edition

Massimo Banzi, Michael Shiloh

Publisher Resources

ISBN: 9781449321185Errata Page