Some friends of mine contacted about this problem that occured during a University project they were working on. After uploading the code below, every uploading attempt gives an error. Usually this:
Arduino: 1.8.4 (Windows 10), Board: "Arduino/Genuino Uno"
Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x51
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x51
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I suspect that the reason behing this is the fact that there is no delay between the serial prints and that keeps serial constantly busy. The code works fine without the prints. I saw a few similar posts, but nothing worked so far.
Some of the suggestions we already tried:
Different IDE versions.
Different computers.
Pressing reset button before uploading. Actually reset didn't seem to work at all (no LEDs blinking).
Plugging the cable right before upload starts. Some people claimed that this did the trick for them, but I tried many times with no success.
Different Arduinos. Both now have the same issue.
Checking the port that the arduino is (The only available I mean).
Their project is now over (thankfully I had a spare Arduino) but i have two useless in my hands and i was wondering if there is some way of fixing them. It seems like a waste to just throw them away.
P.S. I tried these with no connections on the arduino, just the usb cable.
Bill_98:
I suspect that the reason behing this is the fact that there is no delay between the serial prints and that keeps serial constantly busy.
I've run many programs that did this on my Unos over the years and it never caused a problem.
Remove any connections to pins 0 and 1 on your Arduino board. These pins are used for communication with your computer, including uploads. Connecting anything to these pins can interfere with uploads.
Make sure you have selected the port of your Arduino board from the Tools > Port menu.
Sometimes the port will be labeled with the board name in the menu. Other times it will not. If you don’t know which port is your Arduino, you can find it like this:
Unplug your Arduino board from the computer.
Tools > Port
Note the ports, if any, listed in the menu.
Close the Tools menu. The ports list is only updated when the Tools menu is re-opened, so this step is essential.
Plug your Arduino board into the computer.
Tools > Port - The new port listed in the menu is your Arduino board.
I think the only remaining thing you can try is burning the bootloader.
You will need an ISP programmer. If you don’t have a programmer, you can use a spare Arduino board as an "Arduino as ISP" programmer. Although the "Arduino as ISP" only works for programming targets of the AVR architecture, you can use boards of any architecture as an "Arduino as ISP" programmer.
The following instructions are for using an Arduino board as an "Arduino as ISP" programmer. If you have a dedicated programmer, you can skip to the next set of instructions.
Make the following connections between the Arduino board you will be using as the programmer and the target. Refer to the "Connections" table on the SPI library reference page to determine the pins:
The connections are correct. You might check your jumper wires to make sure they have continuity through them. An occasional jumper wire has a bad connection and doesn't conduct electricity. Other than that, the ATmega328P is probably dead. I noticed the sketch you posted is about motors. Connecting a motor incorrectly to an Arduino board is a common way to destroy them.
Bill_98:
I found no option about the Processor though.
My instructions were intended to work for a variety of boards. The Uno doesn't have any custom Tools menus like Tools > Processor, so all you need to do is select Tools > Board > Arduino Uno.
All jumper wires returned a resistance of 2-3ohms, so I suppose the problem is not there. It seems it is time to start looking for some new arduinos. Thanks for the quick replies and the detailed explanations.