23

I wanted to make a fairly simple circuit which would flash a series of LEDs in sequence, using my Arduino Uno (more specifically, a SainSmart clone). I wrote my sketch and it compiled fine. After that, I connected 8 LEDS+resistors to pins 0 through 7, and then connected the Uno to my computer via USB.

I've uploaded sketches successfully in the past, so I'm sure my settings and drivers etc. are correct. However, when I tried to upload my sketch this time, it didn't work.

I tried removing everything I'd connected to the Arduino's pins, and suddenly the upload worked again.

Why does this happen? Does it mean I have to disconnect everything from the board every time I upload a sketch?

2 Answers 2

23

The problem is specifically pins 0 and 1. Although they can be used as regular digital IO pins, they also serve as the RX and TX pins for the Uno's serial port. The USB connection (for uploading sketches etc.) is routed to the same pins internally. Unfortunately that means anything connected on pins 0 and 1 can interfere with the serial connection, preventing communication via USB.

In short, it's not necessary to disconnect everything when uploading a sketch. It should only be necessary to disconnect anything from pins 0 and 1. Rather than going through that hassle every time a sketch is uploaded though, it may be best just to avoid using those pins unless necessary (e.g. you run out of other pins, or your project needs a serial connection to another device).

4
  • 2
    Nice way to teach the community.
    – JVarhol
    Commented Feb 12, 2014 at 13:12
  • 2
    Since the Arduino is also programmed by SPI, which resides on pins 10-13, it is also possible to prevent it from uploading on these pins
    – TheDoctor
    Commented Feb 12, 2014 at 13:56
  • 1
    Well written Q&A! I would love to see more such posts from you :)
    – asheeshr
    Commented Feb 12, 2014 at 15:29
  • 3
    @TheDoctor - Incorrect! The SPI pins are only relevant if you're using an In-System-Programmer. The bootloader programming mechanism does not require the SPI pins at all. Unless you're hooking up a separate, hardware programming tool, this is not something you need to worry about. Commented Feb 24, 2014 at 4:26
1

" Peter R. Bloomfield " I used to upload sketch in my arduino uno by connecting Rx and Tx pin but my sketch get uploaded. Actually problem is arduino uno driver may be deleted in your case

1
  • 1
    This was intended as a reference question. The same person asked and answered the question. I doubt his problem is that the driver was deleted.
    – Nick Gammon
    Commented Nov 1, 2015 at 21:14

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.