I was using my Arduino Uno R3 to drive a servo motor. While updating the sketch, my Arduino stopped showing up as connected in the Arduino IDE. I tried different cables and computers, but nothing worked.
After some investigation, I found that the ATmega16u2 microcontroller, which manages the USB connection, might be the issue. I swapped the IC with one from another Arduino Uno R3 that I know works, and everything started functioning again.
So, it seems that the ATmega16u2 is the only thing not working. I’d like to replace it so I can get both Arduinos working. Is this feasible? I assume I’d need to buy a new ATmega16u2 and program it with the appropriate USB management code, right?
Also, is it possible that something got corrupted in the ATmega16u2, and it could be restored? Is there any way to check that?
All depends on the damage done. You can use a tool called Atmel Flip to check if you can get the faulty 16U2 into DFU mode (using USB) and program it; there are instructions on the web. The other tool can be a programmer (it can be your second Uno with Arduino as ISP loaded) and try to program it using the 6-pin header closest to the 16U2.
I have already replaced the 16U2 from my other working Arduino to make sure that that was the issue so I have the tools and at least a bit of skills so I think it is worth it instead of throwing it away.
The 5V output of the Arduino is intended as a convenience, for at most a couple of LEDs or low power sensors.
It was NOT designed to power any motors or servos, and the electrical hash that those generate in the power leads can and often does lead to the problem you have encountered.
I was able to re-flash the 16U2 and now it's working perfectly! Thanks a lot.
For anyone having the same issue, I followed this guide and performed the flashing with dfu-programmer. I tried first with FLIP but somehow the flashing part was not working (it was able to read the memory tho).