DC Motor Control Options


Looking at the datasheet of this component, can you group together pins by their functions? for example for Power, 3v3, gnd_1 gnd_2 etc
NOTE: If you group them, can you not add the same pin if you already added them in a group? You should know which pin function is common for its function
I grouped every current Arduino Mega2560 terminal into one primary function group only, using the datasheet pin functions and avoiding duplicate pin assignments. Full grouping is in the Arduino Mega2560 Pin Function Groups project file.

Arduino Mega2560 Pin Function Groups
Source: Arduino Mega 2560 Rev3 / A000067 datasheet URL set on this project.
Grouping rule used
Each terminal is assigned to exactly one primary functional group. Where a physical pin has multiple functions, I grouped it by the most specific/common usage called out in the datasheet and did not repeat it in another group.
For example:
  • Pins 0, 1, 14–19 are grouped under UART, not general Digital I/O.
  • Pins 20 and 21 are grouped under I2C/TWI, not External Interrupts or general Digital I/O.
  • Pins 50–53 are grouped under SPI, not general Digital I/O.
  • PWM-capable digital pins are grouped under PWM only if they are not already claimed by UART/I2C/SPI.
  • Pin 13 is grouped under LED/PWM because the datasheet specifically calls out the built-in LED on D13.
  • Duplicate shield-header aliases SDA and SCL are kept as separate physical terminals from digital pins 20 and 21 because this project contains both terminals.
Power / Reference

Table


TerminalSuggested SectionSuggested Pin GroupSuggested Pin TypeNotes
VINPowerPowerPower InExternal input voltage to the board when using an external supply.
+5V_1Power5VPower OutRegulated 5 V rail.
+5V_2Power5VPower OutRegulated 5 V rail.
+5V_3Power5VPower OutRegulated 5 V rail.
+3V3Power3V3Power Out3.3 V output from onboard regulator; datasheet states 50 mA max draw.
IOREFPowerIOREFPower OutLogic-voltage reference for shields.
AREFAnalogAREFPassiveAnalog reference input for analog inputs.
Ground

Table


TerminalSuggested SectionSuggested Pin GroupSuggested Pin TypeNotes
GND1GroundGroundGroundGround pin.
GND2GroundGroundGroundGround pin.
GND3GroundGroundGroundGround pin.
GND4GroundGroundGroundGround pin.
GND5GroundGroundGroundGround pin.
Control / Reserved

Table


TerminalSuggested SectionSuggested Pin GroupSuggested Pin TypeNotes
RESETControlRESETInputBring LOW to reset the microcontroller.
NCNo ConnectNCNot ConnectedRev3 reserved / not connected pin near RESET/IOREF.
UART / Serial

Table


TerminalSuggested SectionSuggested Pin GroupSuggested Pin TypeDatasheet function
0CommunicationUART0InputSerial RX; also connected to ATmega16U2 USB-to-TTL serial chip.
1CommunicationUART0OutputSerial TX; also connected to ATmega16U2 USB-to-TTL serial chip.
19CommunicationUART1InputSerial1 RX.
18CommunicationUART1OutputSerial1 TX.
17CommunicationUART2InputSerial2 RX.
16CommunicationUART2OutputSerial2 TX.
15CommunicationUART3InputSerial3 RX.
14CommunicationUART3OutputSerial3 TX.
I2C / TWI

Table


TerminalSuggested SectionSuggested Pin GroupSuggested Pin TypeDatasheet function
20CommunicationI2CBi-DirectionalSDA / TWI data; also external interrupt 3.
21CommunicationI2CBi-DirectionalSCL / TWI clock; also external interrupt 2.
SDACommunicationI2CBi-DirectionalRev3 SDA header alias near AREF.
SCLCommunicationI2CBi-DirectionalRev3 SCL header alias near AREF.
SPI

Table


TerminalSuggested SectionSuggested Pin GroupSuggested Pin TypeDatasheet function
50CommunicationSPIInputMISO.
51CommunicationSPIOutputMOSI.
52CommunicationSPIOutputSCK.
53CommunicationSPIOutputSS.
PWM / LED / Interrupt-capable digital pins

Table


TerminalSuggested SectionSuggested Pin GroupSuggested Pin TypeDatasheet function
2GPIOPWMBi-DirectionalPWM; external interrupt 0.
3GPIOPWMBi-DirectionalPWM; external interrupt 1.
4GPIOPWMBi-DirectionalPWM.
5GPIOPWMBi-DirectionalPWM.
6GPIOPWMBi-DirectionalPWM.
7GPIOPWMBi-DirectionalPWM.
8GPIOPWMBi-DirectionalPWM.
9GPIOPWMBi-DirectionalPWM.
10GPIOPWMBi-DirectionalPWM.
11GPIOPWMBi-DirectionalPWM.
12GPIOPWMBi-DirectionalPWM.
13GPIOLED_PWMBi-DirectionalPWM; built-in LED connected to D13.
44GPIOPWMBi-DirectionalPWM.
45GPIOPWMBi-DirectionalPWM.
46GPIOPWMBi-DirectionalPWM.
General Digital I/O

Table


Terminal rangeSuggested SectionSuggested Pin GroupSuggested Pin TypeNotes
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43GPIODigitalBi-DirectionalGeneral 5 V digital I/O pins.
47, 48, 49GPIODigitalBi-DirectionalGeneral 5 V digital I/O pins.
Analog Inputs

Table


TerminalSuggested SectionSuggested Pin GroupSuggested Pin TypeNotes
AD0AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD1AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD2AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD3AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD4AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD5AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD6AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD7AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD8AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD9AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD10AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD11AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD12AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD13AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD14AnalogAnalog_InputInputAnalog input, 10-bit ADC.
AD15AnalogAnalog_InputInputAnalog input, 10-bit ADC.
Coverage check
The grouping above covers all terminals currently present in the schematic and avoids assigning any terminal to more than one primary group.
Current terminal count covered: 87 terminals.
Notes from datasheet
  • Board operating voltage: 5 V.
  • Input voltage recommended range: 7–12 V.
  • Input voltage limit: 6–20 V.
  • Digital I/O pins: 54, of which 15 provide PWM output.
  • Analog input pins: 16.
  • UARTs: 4 hardware serial ports.
  • SPI pins: 50 MISO, 51 MOSI, 52 SCK, 53 SS; also broken out on ICSP header.
  • TWI/I2C pins: 20 SDA and 21 SCL, plus Rev3 SDA/SCL header pins near AREF.
  • 3.3 V rail maximum current: 50 mA.
  • Grouping rule used

  • Power / Reference

  • Ground

  • Control / Reserved

  • UART / Serial

  • I2C / TWI

  • SPI

  • PWM / LED / Interrupt-capable digital pins

  • General Digital I/O

  • Analog Inputs

  • Coverage check

  • Notes from datasheet