Changing Arduino Leonardo pins_arduino.h

Hi,

I'm working on a variant of Leonardo which uses Atmega16U4 as its MCU and also have different pin mapping from Leonardo.

I'm trying to change the default pins_arduino.h file and want to remap some of the digital pins like PORTD5 which is the actual TXLED to be a INPUT like it should be Digital Pin 4.

Is there any concern in remapping the pins like the code should stop compiling or it could stop working?

As long as you understand how the pins file is utilized (and do make a backup or keep a copy of the original) there aren't any real concerns about fiddling with it.

Worst-case scenario, you can always reinstall the IDE if things got totally messed up. But just keeping a backup copy of that one file should be all you need.

I've done what you're discussing with Sparkfun's pro micro (a Leonardo clone), created my own pins_arduino.h for it that suited my requirements.

The only other caveat is if you are using any libraries, just make sure you update any hardcoded references they have, eg. the SD card library has d4 hardwired as the chip select pin, so if you've redefined d4 then you might need to modify the library.

Cheers!

Hi!!

Thank you for the comments! I understand that if the file is completely loose I can reinstall the arduino IDE, this is the easy part. :) My concern is about changing a pin that could be related with a Timer a port or something like that and this new mapped pin could interfere with the actual arduino core code. Actually I think my question is: If I remap the pins in the pins_arduino.h file will I need to chance other piece of the arduino code? I know that the RX and TX leds are defined and used on the bootloader (Caterina.c and .h - Leonardo) and also inside the USBCore.cpp so I need to change them. But how to know other parts of the arduino code are related?

Good point about the 3rd party libraries, I'll keep an eye on that.

Thank you.