


During the use of the Arduino IDE, after completing the program and clicking to upload, if there are syntax or other unexpected errors in the program, it will lead to upload failure (or compilation failure). What causes this? Below, several of the most common error prompts will be listed along with perfect solutions.

The following mainly takes the basic program Blink as an example, achieving the effect of controlling the on-board port 13 LED to blink once every second. The correct program is shown in the figure below (commented parts have been removed):
The red box in the figure below is the information prompt box, where you can see the prompt error message:




1. Stuck on uploading… as shown in the figure:
Causes include:
① Incorrect board model selected → re-select the correct board model;
② Incorrect port number selected → you can open the device manager to check the correct port number, formatted as COM+number. Additionally, some desktop and all-in-one computers integrate COM1 and COM2 ports, which are often automatically selected, leading to this problem. The correct method is to disable COM1 and COM2. The method to disable: right-click – disable (how to open device manager can be searched on Baidu).
③ If the error prompt contains Timeout-related words, the cause is related to the above two points, which can be checked one by one.
After being in the uploading… state for a while, it will automatically trigger the error prompt shown below:


2. ‘SomeVariable’ was not declared in this scope
Causes include:
① An undefined variable name, function name (subroutine), etc. appears in the program.
② The defined variable name or function name is correct, but there is an error in its usage, such as int value=1, using it as delay(valye).
The solution is to refer to the prompt line, like line 9, which has a light red background indicating where the problem is in the program, and redefine the variable.


3. Punctuation issues (a beginner’s blessing)
① Too many or too few punctuation marks
There will be prompts at the problematic places, and careful attention will help identify the issues.
② Mixing Chinese and English input methods. When writing programs, make sure that the input method is in English. Chinese can be used in strings and comments, such as:
The error prompt for mixing Chinese and English is as follows:
Is it exactly the same as the previous error? Can you spot the clue? Here’s a tip: English occupies less space, while Chinese occupies more. You can compare and find that the semicolon in English state is “thinner,” while the Chinese one is “fatter” (can be seen through the yellow background):
![]() |
![]() |


4. Library not imported, prompt as follows:
Key error message:
The cause is that in your program you have #include <OneButton.h>, but you have not installed OneButton.h.
Solutions:
① According to the error prompt, which .h file is missing, then search for Arduino OneButton.h library on Baidu. Generally, you can find many results. At this time, you need to be discerning, as the same name may have various implementations. After downloading, you will get at least two files: *.cpp and *.h, and possibly examples. Place these files in a folder and copy them to the libraries folder in the Arduino software directory (next time we will introduce how to install third-party libraries, be sure to scan the QR code at the bottom to follow our public account, you won’t want to miss the useful articles).
② Find the upstream of the project or program, that is, who wrote it, who made it. Generally, you can find it on GitHub, or directly ask me, I might have it. For example, in our challenge of 100 Arduino projects, one of them is a weather forecast, and we even prepared the required Arduino IDE for everyone. The program for this project is still being updated, and the current program version is the Double 11 version. Click the link to view project details (all original materials of the project are open source).


5. As effective as a sharp sword
Searching is an art, self-learning is a skill, and exploration is a habit. Want to be lazy? Sure, just long-press the QR code below, add the editor’s WeChat, and describe your problem clearly, and I will give you a solution directly.
[First Issue] The Correct Posture for Installing Drivers
One issue is not enough to watch? Hurry up and scan the QR code below to follow our public account.