Pls help...
I did not have a programmer and i had a new atmega328p micro controller so i decided to follow this tutorial :
and use the on board 16u2 as a programmer , everything went fine and i flashed my boot loader on atmega328p , then I re-flashed 16u2 with :
Arduino-usbserial-atmega16u2-Uno-Rev3.hex
which changes my uno R3 board back from and avrisp mkii to being an uno , but now it is being recognized as uno R3 but whenever i upload a program it shows :
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x87
(NOTE)^^this code is different every time
and I found another tutorial in which it says this :
"Note: Initially 16U2 will run in the Atmel Studio mode, if you would like to change it, Fit and Unfit a
Link on ICSP1 between pins 5-6 (this will reset the 16U2 and it will change the mode, you will see the LEDs blinking 4-5 times). If you are using Arduino Uno R3, you will need to pull HWB pin to +5V before you use the Reset Link, otherwise your 16U2 will go into DFU mode and will not toggle between Atmel Studio and Avrdude mode."
so i think my board is stuck in Atmel studio mode and i need to switch it to Avrdude mode but i cant understand how to do this , any help will be greatly appreciated
Ok, so you don't need to worry about the 16u2. I don't think that tutorial results in a properly burned bootloader (including proper fuse settings) on the ATmega328P. I recommend getting an ISP programmer such as USBasp with a 6-pin connector, or use another Arduino as an ISP programmer.
Or if you really want to get into intricate detail, study fuse settings by looking in the ATmega328P datasheet and reading online, see in the Arduino IDE built in boards.txt file what the fuse settings should be for an Uno, and investigate how to set those in Atmel Studio while you are repeating the tutorial steps. It could be that tutorial will work with a few more details added.
"Note: Initially 16U2 will run in the Atmel Studio mode, if you would like to change it, Fit and Unfit a
Link on ICSP1 between pins 5-6 (this will reset the 16U2 and it will change the mode, you will see the LEDs blinking 4-5 times). If you are using Arduino Uno R3, you will need to pull HWB pin to +5V before you use the Reset Link, otherwise your 16U2 will go into DFU mode and will not toggle between Atmel Studio and Avrdude mode."
I don't know enough about what he's talking about there, but I'm also fairly confident you don't need to worry about that section since you indicated success in writing the bootloader when you did the ISP programming with Atmel Studio, and also successful restore the 16u2 to normal as proven by the loop back test.
Use AVR studio -> Fuses to set the Fuses. That should fix your problem. Please, let me know if it helped.
I believe, that the Arduino-usbserial-atmega16u2-Uno-Rev3.hex is the correct firmware.
This is about completelly different firmware and it doesnt apply to your situation:
"Note: Initially 16U2 will run in the Atmel Studio mode, if you would like to change it, Fit and Unfit a
Link on ICSP1 between pins 5-6 (this will reset the 16U2 and it will change the mode, you will see the LEDs blinking 4-5 times). If you are using Arduino Uno R3, you will need to pull HWB pin to +5V before you use the Reset Link, otherwise your 16U2 will go into DFU mode and will not toggle between Atmel Studio and Avrdude mode."
yes that is one of the major additional step i took and it was basically done as you mentioned it earlier, and the one other thing i did (and i think this is only required for windows 8/8.1 and 10), is that i used libusb-win32 driver for AVRISP instead of the jungo drivers it automatically installs, this step is very important as without it Atmel Studio cannot connect to the AVRISP, these are the steps i followed to change the drivers:
Download Zadig: http://zadig.akeo.ie/. Zadig is a USB driver manager for Windows, and saved me a hundred times this year. The last version comes with the libusb-win32 (v1.2.6.0) driver embedded.
Open Zadig, Options, List All Devices. The AVRISP mkII device should appear in the list.
Replace its current driver by libusb-win32 (v1.2.6.0)