I had to upload code to my arduino using another arduino due to some the fact that I spoiled the arduino and I cant upload code to it directly.
I used the circuit above from instructables.com Here.
The next steps are:
-
Select the board which you are using to program by going Tools > Board (In my case UNO). Also select toe port of your board by going to Tools > Port.
-
Open the ArduinoISP code which ca be found by going to File > Examples > ArduinoISP.
-
Upload the sketch.
-
After Uploading the sketch, again go to Tools > Board and now select the board which is to be programmed (In my case NANO).
-
Now open the sketch which is to be uploaded.
-
Go to Tools > Programmer and change it to Arduino as ISP.
-
Now go to File and select Upload using Programmer.