Arduino Uno stuck on upload

Perhaps there is some confusion. I'll provide more detailed instructions. Please try this:

Try this:

File > Examples > 11.ArduinoISP > ArduinoISP

Connect the "Arduino as ISP" Uno's USB cable to your computer.

Tools > Port > select the port of your "Arduino as ISP" Uno

Sketch > Upload

Wait for the upload process to finish successfully. Your "Arduino as ISP" Uno now has the sketch installed that allows it to be used as an ISP programmer.

Disconnect the "Arduino as ISP" Uno from the bad Uno.

Connect your "Arduino as ISP" Uno to the bad Uno, with the usual wiring.

Connect the "Arduino as ISP" Uno's USB cable to your computer.

Paste the following sketch into the Arduino IDE:

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("hello");
  delay(1000);
}

Sketch > Upload Using Programmer

Wait for the upload to finish successfully. The "hello" sketch has now been uploaded to the bad Uno via the "Arduino as ISP"

Unplug the "Arduino as ISP" Uno from your computer.

Disconnect the "Arduino as ISP" Uno from the bad Uno.

Connect the bad Uno's USB cable to your computer.

Tools > Port > select the port of your bad Uno

Tools > Serial Monitor

Make sure the baud rate menu near the bottom right corner of the Serial Monitor window is set to 9600.

Do you see "Hello" printed repeatedly in the Serial Monitor? The idea is to see if serial communication is working correctly all the way through between the ATmega328P to the ATmega16U2 to the computer.

NOTE: when you did the "Upload Using Programmer", it erased the bootloader from the bad Uno, which will make it so you can't upload sketches over the USB cable. You can replace the bootloader by connecting the "Arduino as ISP" back to the bad Uno and doing a Tools > Burn Bootloader.


krusion:
I hate that I'm wasting your time with this, I'm sorry.

Don't worry about it. Helping people here on the forum is what I do. I only hope I'll be able to be of assistance.

krusion:
Shouldn't it be done in C code rather than arduino code?

Nope. It's only Arduino language code or C code on the computer. The compiler converts either one to binary machine code, and that's what gets uploaded to the Uno. As long as you're using a language that can be compiled to machine code, it doesn't matter.