I have searched this topic almost everywhere also got different results that couldn't satisfy me

My new project is a 4x4 LED cube

Of which

Will contain 4 Rows and each Row will contain 16 LEDs

So, I need to use all the digital pins 0-15 as digital output.

And other pins 16-20 for grounding.

But the problem is, this project needs d0 and d1 pin to be connected as a digital output pin. (Not Serial communication)

In some places I have seen that Experts saying

  1. If you want to use Serial communication, then you can't use them.
  1. You can't use it while your arduino is connected to PC.
  1. You Can't do this ,as this may harm the device
  1. You must turn off serial connection first.

OK, reading this, I got confused, I don't need to use any serial connection (console and others) in this LED cube project so I tried to turn off serial connection by not writing the code below.


So, will that free those d0 and d1 pins as digital for me ? Or USB connection is also considered as a serial connection?

So, how can I do it? And will doing it really harm my board?

2 Answers 2


If you don't use the serial port, pins 0 and 1 are regular I/O pins. It's just as simple as that.

If you want to use Serial communication, then you can't use them.


You can't use it while your arduino is connected to PC.

Wrong. You can keep the USB cable connected as a power supply. You will not be able to use it for communication though.

You Can't do this, as this may harm the device

What is “this”? The device can be harmed if you drive too much current to/from an I/O pin, irrespective of whether it's a pin that could be used for serial communication.

You must turn off serial connection first.

Only if you did turn it on before. If you never enable Serial, you don't have to do anything more.

  • An LED consumes approximately 3 volts and 30 mA (maximum rate) and the output of arduino pins are 5 volt and 40 mA, so , this shouldn't harm my board, so, Not writing the code 'Serial.begin(9600);' code will solve my problem right? Sep 26, 2020 at 10:12
  • @SubhaJeetSikdar: 40 mA is the “absolute maximum rating”. Under normal working conditions, you should normally not source more than 20 mA from a single pin. Note that there are also limits on the sum of the currents sourced by a single port. See the datasheet. Sep 26, 2020 at 10:15

The bootloader always turns UART0 on upon the loading of the code to your Arudino Nano. So at the end of the day pins D0 and D1 are used for their alternate functions as a UART receiver and transmitter without you doing so in your code.

Copy the following code to whatever your sketch or C program to disable the UART0 module before you initalize pins d0 and d1 as digital IO, then you can set the two pins as digital I/Os as usual and they will work perfectly.

UCSR0B &= ~(1<<3);
UCSR0B &= ~(1<<4);
  • the Arduino init() does this github.com/arduino/ArduinoCore-avr/blob/…
    – Juraj
    Dec 21, 2021 at 4:34
  • Thanks for the information. I recommend using register accessing to be more generic for the ones -like me- who are developing code on Eclipse using C and loading it to the ATmega328P on the Arduino Nano. I'm not using the Arduino IDE. Dec 21, 2021 at 17:44
  • then put that disclaimer in the answer so people don't start to put those two lines in Arduino sketches
    – Juraj
    Dec 21, 2021 at 18:34
  • FYI I tried putting the two lines of codes in an arduino sketch and it worked. Thanks for your concern. Dec 22, 2021 at 5:47
  • of course it works, but it is redundant
    – Juraj
    Dec 22, 2021 at 5:57

Your Answer

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

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