You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/03.nano/boards/nano-esp32/tutorials/pin-setup/pin-setup.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,20 +14,20 @@ The [Arduino Nano ESP32](https://store.arduino.cc/nano-esp32) is a Nano form fac
14
14
This means that if you want to control a pin you can simply use the pin number that is printed on the board itself:
15
15
16
16
```arduino
17
-
// This will enable the pin marked with "8" on the board:
17
+
// This will enable the pin marked with "D8" on the board:
18
18
digitalWrite(8, HIGH);
19
19
```
20
20
21
21
### Compatibility Mode
22
22
23
-
However, some libraries previously written for ESP32 boards (to name a few: OneWire, FastLED, ESP32Servo) don't support the pin numbers printed on the board and require you to refer to the internal microcontroller's GPIO number instead. For instance, to refer to the pin labelled "8" on the board such libraries expect you to write `17` in your code as that's the GPIO number corresponding to that pin.
23
+
However, some libraries previously written for ESP32 boards (to name a few: OneWire, FastLED, ESP32Servo) don't support the pin numbers printed on the board and require you to refer to the internal microcontroller's GPIO number instead. For instance, to refer to the pin labelled "D8" on the board such libraries expect you to write `17` in your code as that's the GPIO number corresponding to that pin.
24
24
25
25
For this purpose, we added a compatibility mode so that you can choose which numbering scheme you want to use:
26
26
27
27
* when porting an existing Arduino project from another Nano board, it's convenient to use the "Arduino pin" scheme which reflects the numbers printed on the board
28
28
* when using third-party libraries for ESP32, you should use the "GPIO number" scheme which corresponds to the internal numbers
29
29
30
-
To change this configuration, simply connect your board, go to **Tools > Pin Numbering > Select Option**. More details are available in this tutorial.
30
+
To change this configuration, simply connect your board, go to **Tools > Pin Numbering** and then select your option. More details are available in this tutorial.
31
31
32
32
## Software & Hardware Needed
33
33
@@ -41,12 +41,12 @@ So why does the Nano ESP32 pins not match the ESP32 (MCU) pins? The Nano ESP32 w
41
41
42
42
This makes it possible to migrate an older Nano board, to a newer generation Nano (like the Nano ESP32), without having to change your hardware setup.
43
43
44
-
This of course brings a separate issue, which is that by default, the Nano ESP32 does not use the ESP32's pinout. An example of this is:
45
-
- Pin `2` is actually `5`
46
-
- Pin `5` is actually `8`
44
+
This of course brings a separate issue, which is that this numbering does not match the ESP32's native GPIO assignment. An example of this is:
45
+
- Pin `2` is actually GPIO `5`
46
+
- Pin `5` is actually GPIO `8`
47
47
- and so on (see the full [pin map](#nano-esp32-pin-map)).
48
48
49
-
It is common in a board's design that the actual microcontroller's pins doesn't match the header pins.
49
+
It is common in a board's design that the actual microcontroller's pins don't match the header pins.
50
50
51
51
### Default & Legacy Options
52
52
@@ -72,18 +72,16 @@ pinMode(5, OUTPUT);
72
72
73
73
You can also control pins using labels such as `D0`, `D1`, `D2`. These labels are predefined in the core, and are adjusted based on what configuration you make.
74
74
75
-
For example, if you are using the `GPIO number (legacy)` option:
75
+
For example, the following code will access the same pin, regardless of what configuration you use:
76
76
77
77
```arduino
78
78
/*
79
79
This will configure the "D2" physical pin on your board
80
-
(but will internally configure pin 5 on the ESP32)
80
+
(but will internally configure GPIO 5 on the ESP32)
81
81
*/
82
82
pinMode(D2, OUTPUT);
83
83
```
84
84
85
-
86
-
87
85
## Change Pin Configuration
88
86
89
87
To change the pin configuration, open the Arduino IDE, and navigate to **Tools > Pin Numbering.** Here you can select between the default (Nano) and legacy (ESP32) options.
0 commit comments