My 3d printer, Creality Ender 4, has an ATmega 2560 chip based card, and I need to identify the number associated with a particular Pin. I read, on the official Arduino website, a simple tutorial in which through a small led connected to two pins of the card, you wrote a code (sketch) that made it turn on, but you had to know the Pin number. I would like to do this on my board, I unplug all cables (power supply, motors, etc.) and connect it to the PC via USB and from Arduino IDE, I execute the code, connecting the LED on the ground and on the signal (see image).enter image description here To identify the Pin number I thought I would go to exclusion, because I know all the PIN numers of the chip, until the LED lights up. So I ask, is that correct? is there a chance of damaging the card? or is there a better method? Thanks in advance

  • 1
    not correct because the microcontoller pins are not directly connected to peripheral plugs on the board ... yes, the board could be damaged ... it is better to obtain a schematic diagram or at least a table of pin functions
    – jsotola
    Nov 21, 2020 at 1:11
  • The 3dpinter/board manufacturer don't want give me the schematics, or just the number I need. On the internet there is very little info about the board...
    – David
    Nov 21, 2020 at 8:14
  • 2
    I'd suggest using a multimeter in continuity mode, on the unpowered board. Then check which MCU pin is connected to the pin you're looking at.
    – Gerben
    Nov 21, 2020 at 14:02

1 Answer 1


Disconnect everything but the switch.
Run this:

for each pin,
  set the pin to INPUT_PULLUP mode;
    read and print the pin number and pin state;
  until operator touches a key;
  read and discard the serial input;

You do:

  • Each time a new pin number prints on the terminal, toggle the switch a few times to confirm whether you are seeing the result of your actions.
  • If not, touch the spacebar to try the next pin #
  • else, you found it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.