So I am programming for Arduino for some weeks now and never had problems. Until today. I created a very basic script; it simply writes "Application started" in the serial monitor. It's not rocket science. After a while I get this error:
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.
An error occurred while uploading the sketch
No other information is given. I also have PlatformIO installing in Visual Code and I grabbed that one to test it my Arduino Uno is broken; this is not the case since I can upload the same code and it works.
Back to Arduino IDE: I tried uploading it again and it worked again. But after a while I got the same error.
I tried these things:
Reconnect the Arduino to the laptop (windows); no luck
Restarted the laptop: no luck
Tried different ports: no luck
Tried Arduino online: worked, but not ideal for me
Reinstalled Arduino IDE: no luck
Search internet: A lot of information not applicable to my problem, so no luck
Tried an other board: no luck
Tried a different USB cable: no luck
If I see all these bullets and the results, I think it is a problem with arduino IDE. I am using the latest version (1.8.9) on a Windows 10 laptop with an Arduino UNO. There is nothing on the board (sensors and stuff).
I don't know what to do next. Does anybody have a clue?
johnwasser:
In Preferences, set "Show verbose output during: [ ] compilation [X] upload"
Alright, I turned it on. It seems to be working for now. All I did was Sketch -> Verify/compile. Uploading seems to be working again. As soon as I got the error again I will return to this topic.
I finally happens again! So, I have nothing connected to my board, just the USB cable from the Arduino to the laptop. The sketch is completely empty (apart from the setup and look). I get this message:
avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : usb
Using Programmer : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)
Similar to what septillion replied while I was writing my reply, but I'll post it anyway because there is some additional information:
This error indicates you're doing an "Upload Using Programmer" instead of a standard "Upload". If you hold the shift key when clicking the "Upload" button, it will cause the Arduino IDE to do an "Upload Using Programmer" instead. So make sure not to press the shift key when you click the "Upload" button. The other way to trigger an "Upload Using Programmer" is via Sketch > Upload Using Programmer or the Shift + Ctrl + U keyboard shortcut.
septillion:
If you have the Arduino connected only via USB, why did you select Upload using programmer?
Yup, that is the solution. Well, not in detail, but the "using programmer" give me a hint to look further into it. Google gave me a link to the correct solution. It works now. Thank you all!