Disable LED on Pin 13 While Uploading Sketch


I am finishing up a senior design project which uses the Mega 2560 board and I have relay driver circuitry wired to the Arduino digital pin 13. The Arduino attaches to a custom designed PCB via the Arduino board headers.

I've noticed that the LED on pin 13 blinks while a sketch is being uploaded or the board is resetting which is then engaging and disengaging the relay also tied to pin 13.

Is there any way to disable this pin 13 "blinking" while resetting or uploading a sketch? I'd like to limit the number of actuations on the relay so as to not decrease its lifespan.

I realize I should have considered this in my PCB design but now that it's been fabbed and assembled I'm looking for a way around.

The blinking of pin 13 is done by the bootloader. There is no way to disable that in your sketch code. You have two options:

1st option: Recompile the bootloader with the blink disabled or moved to a convenient pin and then burn the customized bootloader to your board. If you decide to go this route, I would recommend using the Optiboot bootloader, which is easier to compile than the bootloader used on the official Arduino Mega. That said, some people do have a lot of trouble getting things set up to compile even the Optiboot bootloader.

Optiboot repo:

Repo that contains the build scripts for Optiboot as used on the MegaCore hardware package:

2nd option: Don't use a bootloader. If you connect an ISP programmer to your board and then upload your sketch using the Arduino IDE's Sketch > Upload Using Programmer feature, it will erase the bootloader and thus you will no longer have the bootloader blink on pin 13. After doing that, you will no longer be able to do standard uploads via the Arduino IDE until you have done a Tools > Burn Bootloader with your ISP programmer to reinstall the bootloader. If you don't own an ISP programmer you can use a spare Arduino board as an "Arduino as ISP".

The 2nd option seems much more simple to me, but it may depend on how easy it is to connect an ISP programmer to your custom board.