<p>The pin mapping that Marlin uses is defined in the file <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/fastio_1280.h" rel="nofollow noreferrer">fastio_1280.h</a>:</p>

<pre><code>/**
 * Pin mapping for the 1280 and 2560
 *
 *   1280     22 23 24 25 26 27 28 29 53 52 51 50 10 11 12 13 37 36 35 34 33 32 31 30 21 20 19 18 81 82 83 38 00 01 78 05 02 03 79 80 54 55 56 57 58 59 60 61 41 40 39 71 70 04 17 16 84 06 07 08 09 85 15 14 72 73 75 76 77 74 62 63 64 65 66 67 68 69 49 48 47 46 45 44 43 42
 *   Port     A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 G0 G1 G2 G3 G4 G5 H0 H1 H2 H3 H4 H5 H6 H7 J0 J1 J2 J3 J4 J5 J6 J7 K0 K1 K2 K3 K4 K5 K6 K7 L0 L1 L2 L3 L4 L5 L6 L7
 *   Marlin   00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
*/
</code></pre>

<p>Confusingly, the line labeled "1280" refers to the pin numbers as used by Marlin. The line labeled with "port" gives the corresponding port/pin combination as it applies to the AtMega2560 chip itself. To translate between the port numbers given above, and the Arduino Mega pin numbers, you can use the following pinout diagram:</p>

<p><a href="https://i.sstatic.net/zGS6B.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zGS6B.jpg" alt="Arduino Mega Pinout"></a>
<em>Licensed under CC-BY-SA, www.bq.com</em></p>

<p>For instance, according to the pin mapping in <code>fastio_1280.h</code>, Marlin pin 34 is "port" C3. This corresponds to PC3 in the pinout diagram, which is Arduino Mega A11. Conversely, if we want to find out what PWM pin 9 is in Marlin, we can look at the diagram to find out it corresponds to PH6, which is Marlin pin 09.</p>

<p>If you want to change this numbering, then unfortunately, you have to make quite a few modifications to fastio_1280.h. For instance, the "reason" pin 5 corresponds to the pin it does, is the following set of definitions:</p>

<pre><code>#define DIO5_PIN    PINE3
#define DIO5_RPORT  PINE
#define DIO5_WPORT  PORTE
#define DIO5_DDR    DDRE
#define DIO5_PWM    &amp;OCR3AL
</code></pre>

<p>If you wanted to point pin 5 towards another pin, you'd need to change all of these lines to point to the correct registers and pin numbers.</p>

CC BY-SA 3.0
2018-01-05T09:13:47.370Z
2018-01-05T09:59:11.160Z
2018-01-05T09:59:11.160Z
Tom van der Zanden
<p>I am designing my own shield for the MEGA2650 that I will use to control my printer. </p>

<p>When defining pins in the marlin firmware, the pin numbers are the pin numbers of the RAMPS shield and not the Arduino MEGA itself.</p>

<p>How can I define pins so that I could write <code>#define HEATER1PIN 5</code> and it will make heater1pin be on <em>Arduino MEGA's</em> pin 5 and <strong>NOT</strong> <em>RAMPS's</em> pin 5</p>

<marlin><reprap><firmware><arduino-mega-2650>
How do I use MEGA pin number designations rather than RAMPS pin numbers in marlin
12345
# How do I use MEGA pin number designations rather than RAMPS pin numbers in marlin

(Asked by: username_0 on 2018-01-04)

I am designing my own shield for the MEGA2650 that I will use to control my printer.

When defining pins in the marlin firmware, the pin numbers are the pin numbers of the RAMPS shield and not the Arduino MEGA itself.

How can I define pins so that I could write `#define HEATER1PIN 5` and it will make heater1pin be on *Arduino MEGA's* pin 5 and **NOT** *RAMPS's* pin 5

**Tags:** marlin, reprap, firmware, arduino-mega-2650


---

## 1 answers

### Answer by username_1 on 2018-01-05. Score: 3 | Accepted answer

The pin mapping that Marlin uses is defined in the file [fastio\_1280.h](https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/fastio_1280.h):

```
/**
 * Pin mapping for the 1280 and 2560
 *
 *   1280     22 23 24 25 26 27 28 29 53 52 51 50 10 11 12 13 37 36 35 34 33 32 31 30 21 20 19 18 81 82 83 38 00 01 78 05 02 03 79 80 54 55 56 57 58 59 60 61 41 40 39 71 70 04 17 16 84 06 07 08 09 85 15 14 72 73 75 76 77 74 62 63 64 65 66 67 68 69 49 48 47 46 45 44 43 42
 *   Port     A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 G0 G1 G2 G3 G4 G5 H0 H1 H2 H3 H4 H5 H6 H7 J0 J1 J2 J3 J4 J5 J6 J7 K0 K1 K2 K3 K4 K5 K6 K7 L0 L1 L2 L3 L4 L5 L6 L7
 *   Marlin   00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
*/

```

Confusingly, the line labeled "1280" refers to the pin numbers as used by Marlin. The line labeled with "port" gives the corresponding port/pin combination as it applies to the AtMega2560 chip itself. To translate between the port numbers given above, and the Arduino Mega pin numbers, you can use the following pinout diagram:

[![Arduino Mega Pinout](https://i.sstatic.net/zGS6B.jpg)](https://i.sstatic.net/zGS6B.jpg)
*Licensed under CC-BY-SA, www.bq.com*

For instance, according to the pin mapping in `fastio_1280.h`, Marlin pin 34 is "port" C3. This corresponds to PC3 in the pinout diagram, which is Arduino Mega A11. Conversely, if we want to find out what PWM pin 9 is in Marlin, we can look at the diagram to find out it corresponds to PH6, which is Marlin pin 09.

If you want to change this numbering, then unfortunately, you have to make quite a few modifications to fastio\_1280.h. For instance, the "reason" pin 5 corresponds to the pin it does, is the following set of definitions:

```
#define DIO5_PIN    PINE3
#define DIO5_RPORT  PINE
#define DIO5_WPORT  PORTE
#define DIO5_DDR    DDRE
#define DIO5_PWM    &OCR3AL

```

If you wanted to point pin 5 towards another pin, you'd need to change all of these lines to point to the correct registers and pin numbers.


---

