可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I've uploaded a sketch to an Arduino Uno whose loop is something like this:
void loop(){
Serial.println("Hello World");
}
So, now, I can't upload anything anymore, because the IDE says "port already in use".
Is there a way to "reset" the Arduino without another programmer?
EDIT :
Nothing else is using the serial port, and everything went just fine until I uploaded the previous sketch.
EDIT :
I've found some interesting things:
- Problems with 0021 on Ubuntu 10.04 Lucid Lynx
- Re: Problems with 0021 on Ubuntu 10.04 Lucid Lynx
- Uno sending serial data becomes un-connectable to Serial Monitor
回答1:
Try the following:
- Prepare the basic empty program (empty setup, loop, etc.)
- Compile it.
- Reset the Arduino using the hardware button on the chip
- Press Ctrl + U to upload your code.
- If unsuccessful - got to 3.
There is a delay before the boot loader starts the programs, just work on your timing. It worked for me when a bug in my Arduino's code was executing a soft reset every 500 ms.
回答2:
I had the same problem on two Arduinos (one Uno, and one Modern Device Freeduino/USB Host board) and the window between reset and the beginning of serial port usage was so small that it was impossible to upload.
I finally fixed the problem by purchasing another Arduino Uno and building an ISP cable per these instructions, and using it to flash the Bare Bones app from the examples into each inaccessible board, using Arduino IDE version 0023, following these instructions to change preferences.txt. (Be sure to save the original file before editing it so you can replace it after you've rescued your Arduino.)
It took one quick upload to fix each board. Such a fast fix after so much grief. You might not want to purchase another Arduino, but consider these benefits:
- You can overwrite the bootloader on your Arduino to gain more space.
- Once the bootloader is overwritten, the board will boot faster.
- Supposedly you can program raw AVRs for special projects, but I have not tried this: Google for ArduinoISP
- It will quickly fix Arduinos that you block in the future.
- You can now safely experiment to find ways to prevent serial port usage from locking up the device in the future.
回答3:
Make sure you plug arduino directly in computer and not through a hub. Using a hub will give you this error.
回答4:
Based on my experience with the communication already in use or blocked I would say that the program you are interfacing with still has the communication open. I also found that if you disconnect the USB cable it will rest the communication. It is not the greatest solution but it solves the problem. I hope that helps.
回答5:
I just spent the last 5 hours searching for a solution to this problem (serial port COM3 already in use, grayed out serial port)...I tried everything every forum I could find suggested, including this one..
What finally fixed it (got rid of the last code i'd input that got stuck and uploaded simple blink function)? Follow this link -- http://arduino.cc/en/guide/windows and follow the instructions for INSTALLING THE DRIVERS. My driver was "already up to date", but following these steps fixed the glitch. I am now a happy camper once again.
Note: Resetting the board manually with the button on the chip, or digitally through misc. codes on the internet did not work to fix this problem because the signal was somehow blocked/confused between my arduino uno and the port in my laptop. Updating the drivers is like a reset for the "serial port already in use" problem.
At least so far..
回答6:
After scratching my head about this problem, here a very simple SOLUTION that work anytime:
- Unplug your USB Cable
- Go in your DEVICE MANAGER
- Click on Ports (COM & LPT)
- Right Click on Arduino....(COMx)
- Properties
- Port Settings
- Put Flow Control to HARDWARE
- Create an empty sketch (*Optional)
- Connect the USB Cable
- Upload (Ctrl - U)
// Emtpy Sketch to fix upload problem
// Create by Eric Phenix
// Nov 2014
void setup()
{
}
// the loop routine runs over and over again forever:
void loop()
{
delay(1000);
}
Et voila!
Eric
回答7:
Be sure you are not accesing the serial port from a terminal, that loop (or any code) should not prevent the Arduino from being programmed.
回答8:
If you still have the serial console open, it will reserve the serial port. Close it, and try again.
回答9:
For Arduino Yun users, try uploading via Ethernet/WiFi (Tools->Port).
I had exactly the same problem, I tried pretty much everything (apart of burning new bootloader). I am surprised it worked, but I've uploaded empty sketch without any problem.
回答10:
I got similar problem.
If i power on myarduino There is delay before uploaded program execute.
So i use that delay for uploading new program, or empty program:
void setup(){}
void loop(){}
so my problem solved.
Unplug any connection to arduino pins before upload.
回答11:
Here's what I did in Linux to be able to program my Arduino Micro which was stuck in a loop sending the 0 key when connected by USB;
# while true; do xinput float $(xinput --list | grep -i Arduino | awk '{print $7}' | cut -d'=' -f 2); done
Your output might be slightly different so just try running;
# watch xinput --list
then plug in the Arduino and see how the output is formatted.
This stopped X from accepting the keypresses and allowed the Arduino IDE to program finally!
回答12:
I had this issue as well, I tried the above methods and none seemed to work, however something that did work (somehow, not sure if it was just a freak thing or it is actually a way to do it)
- Unplug USB from duino
- Press and hold reset button
- Plug in USB and power up
- continue holding and upload the sketch. Once it's done uploading release the reset button.
回答13:
I had the very same problem today. Here is a simple solution we found to solve this issue (thanks to Anghiara):
Instead of loading your new codes to the arduino using the "upload button" (the circle with the green arrow) in your screen, use your mouse to click "Sketch" and then "Upload".
Please remember to add a delay() line to your codes when working with serial.println() and loops. I learned my lesson the hard way.
回答14:
Arduino Leonardo Board
- UnPlug the USB cable
- Connect the Rx Pin With Ground
- Plug the USB cable
- Upload a new program
- Remove the USB cable
- Remove Rx grounding
That work for me, I hope to you too.
回答15:
If the port says Already used, then you are probably using the wrong port.
switch it to the port were you connected your arduino and
then try to re-upload, you will definitely see it work.
回答16:
If nothing helped then you should arrange one more board and try to flash it through Arduino as ISP option as shown here https://www.arduino.cc/en/Tutorial/ArduinoISP or https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard. instead of boot loader you can select your own programs to flash via ISP
回答17:
- Unplug Tx from the microcontroller
- Insert USB cable
- Wait until full load
- Connect Rx with hardware
- Compile empty sketch in prosses and unconnect tx (don't worry about the error)
- Connect Rx with hardware
- Compile empty sketch
- Power off and connect Tx
回答18:
I have your problem too and I solved the problem using the following steps:
(Though you may already finish the problem, it just shares for anyone who visit this page)
- unplug your arduino
- prepare empty setup and empty loop program
- write a comment symbol '//' at the end of program
- set your keyboard pointer next to '//'symbol
- plug your arduino to computer, wait until the arduino is completely bootloaded and it will outputs 'Hello World'
- You will see the 'Hello World' outputting script will be shown as comment, so you can click [upload] safely.
Hope it help.
回答19:
1.First of all connect you aurduino device .
2.Then go to device manager and uninstall driver.
3.Now remove your aurduino device.
4.Again connect you aurduino device to your system.
5. Now install your driver (which you have uninstalled earlier).
It will free your port for sure.
回答20:
Here is the best way that works out if you are trying to program through the USB cable:
- Ground the Tx signal on the board (connect digital I/O #1 to GND)
- Plug the USB cable
- Upload a new program
- Remove the USB cable
- Remove Tx grounding
You are all set!