我怎样才能“重置” Arduino 板?

发布于 2024-10-21 20:53:01 字数 769 浏览 3 评论 0 原文

我已经将 sketch 上传到 Arduino Uno,其循环如下:

void loop(){
    Serial.println("Hello, World!");
}

所以,现在,我无法再上传任何内容,因为 IDE 说“端口已在使用中”。

有没有一种方法可以在没有其他程序员的情况下“重置”Arduino?

没有其他东西使用串行端口,一切都很顺利,直到我上传之前的草图。

我发现了一些有趣的事情:

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?

Nothing else is using the serial port, and everything went just fine until I uploaded the previous sketch.

I've found some interesting things:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(21

初吻给了烟 2024-10-28 20:53:02

尝试以下操作:

  1. 准备基本的空程序(空设置、循环等)
  2. 编译它。
  3. 使用芯片上的硬件按钮重置 Arduino
  4. Ctrl + U 上传代码。
  5. 如果不成功 - 则转到 3。

引导加载程序启动程序之前有一个延迟,只需按您的时间安排即可。当我的 Arduino 代码中的错误每 500 毫秒执行一次软重置时,它对我有用。

Try the following:

  1. Prepare the basic empty program (empty setup, loop, etc.)
  2. Compile it.
  3. Reset the Arduino using the hardware button on the chip
  4. Press Ctrl + U to upload your code.
  5. 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.

待"谢繁草 2024-10-28 20:53:02

我在两个 Arduino(一个 Uno 和一个 Modern Device Freeduino/USB 主机板)上遇到了同样的问题,并且重置和开始使用串行端口之间的窗口非常小,以至于无法上传。

我最终通过购买另一个 Arduino Uno 并按照这些说明构建 ISP 电缆解决了这个问题,并使用使用 Arduino IDE 版本 0023,按照 这些,将示例中的 Bare Bones 应用程序闪存到每个无法访问的板中更改preferences.txt的说明。 (请务必在编辑之前保存原始文件,以便在拯救 Arduino 后可以替换它。)

需要快速上传才能修复每个板。在经历了如此多的悲伤之后,如此快速的修复。您可能不想购买另一个 Arduino,但请考虑以下好处:

  • 您可以覆盖 Arduino 上的引导加载程序以获得更多空间。
  • 一旦引导加载程序被覆盖,主板将启动得更快。
  • 据说你可以为特殊项目编写原始AVR,但我还没有尝试过这个:Google for ArduinoISP
  • 它会快速修复你将来阻止的Arduino。
  • 您现在可以安全地进行试验,寻找防止将来使用串行端口锁定设备的方法。

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.
望她远 2024-10-28 20:53:02

Arduino Leonardo 板:

  1. 拔下 USB 线
  2. 将 RX 引脚接地
  3. 插入USB 线
  4. 上传新程序
  5. 移除 USB 线
  6. 移除 RX 接地

Arduino Leonardo board:

  1. Unplug the USB cable
  2. Connect the RX Pin to ground
  3. Plug in the USB cable
  4. Upload a new program
  5. Remove the USB cable
  6. Remove the RX grounding
怪我闹别瞎闹 2024-10-28 20:53:02

确保将 Arduino 直接插入计算机,而不是通过集线器。使用集线器会出现此错误。

Make sure you plug the Arduino directly into the computer and not through a hub. Using a hub will give you this error.

虐人心 2024-10-28 20:53:02

在我对这个问题摸不着头脑之后,这里有一个非常简单的解决方案,可以随时使用:

  • 拔掉 USB 电缆,
  • 进入 设备管理器
  • 单击端口(COM 和 LPT)
  • 右键单击​​ Arduino....(COMx)
  • 属性
  • >端口设置
  • 流量控制置于硬件
  • 创建一个空草图(可选
  • 连接 USB 电缆
  • 上传(Ctrl + U

// Empty sketch to fix the upload problem
// Created by Eric Phenix
// Nov 2014

void setup()
{
}

// The loop routine runs over and over again forever:
void loop()
{
    delay(1000);
}

瞧!

After scratching my head about this problem, here is a very simple solution that works anytime:

  • Unplug your USB cable
  • Go in 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)

// Empty sketch to fix the upload problem
// Created by Eric Phenix
// Nov 2014

void setup()
{
}

// The loop routine runs over and over again forever:
void loop()
{
    delay(1000);
}

Et voila!

〃安静 2024-10-28 20:53:02

如果您仍然打开串行控制台,它将保留串行端口。关闭它,然后重试。

If you still have the serial console open, it will reserve the serial port. Close it, and try again.

梦里寻她 2024-10-28 20:53:02

这是我在 Linux 中所做的,以便能够对我的 Arduino Micro 进行编程,当通过 USB 连接时,它陷入了发送 0 键的循环中;

# while true; do xinput float $(xinput --list | grep -i Arduino | awk '{print $7}' | cut -d'=' -f 2); done

您的输出可能略有不同,因此只需尝试运行;

# watch xinput --list

然后插入 Arduino 并查看输出的格式。

这阻止了 X 接受按键并最终允许 Arduino IDE 进行编程!

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!

鸵鸟症 2024-10-28 20:53:02

根据我对已在使用或被阻止的通信的经验,我会说您正在连接的程序仍然具有开放的通信。

我还发现,如果您断开 USB 电缆,通信将会中断。这不是最好的解决方案,但它解决了问题。

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.

贱人配狗天长地久 2024-10-28 20:53:02

对于Arduino Yún用户,请尝试通过上传以太网/Wi-Fi(菜单工具端口)。

我遇到了完全相同的问题,并且我尝试了几乎所有方法(除了刻录新的引导加载程序)。我很惊讶它有效,但我上传了一个空草图,没有任何问题。

For Arduino Yún users, try uploading via Ethernet/Wi-Fi (menu ToolsPort).

I had exactly the same problem, and I tried pretty much everything (apart from burning a new bootloader). I am surprised it worked, but I've uploaded an empty sketch without any problem.

冰葑 2024-10-28 20:53:02

我刚刚花了最后五个小时寻找这个问题的解决方案(串行端口 COM3 已经在使用中并且串行端口变灰)...我尝试了我能找到的所有论坛和问答网站的建议,包括这个..是

什么最终修复了它(摆脱了我输入的最后一个被卡住的代码并上传了简单的闪烁功能)?

请点击此链接 - http://arduino.cc/en/guide/windows 并关注安装驱动程序的说明。我的驱动程序“已经是最新的”,但按照这些步骤修复了故障。我现在再次成为一名快乐的露营者。

注意:使用芯片上的按钮手动重置电路板,或通过互联网上的各种代码以数字方式重置电路板并不能解决此问题,因为信号在我的 Arduino Uno 和我笔记本电脑中的端口。更新驱动程序就像重置“串行端口已在使用”问题一样。

至少到目前为止...

I just spent the last five hours searching for a solution to this problem (serial port COM3 already in use and grayed out serial port)...I tried everything every forum and Q&A site 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 miscellaneous 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...

满天都是小星星 2024-10-28 20:53:02

我也有这个问题。我尝试了上述方法,但似乎都不起作用,但是确实起作用的东西(不知何故,不确定这只是一个奇怪的事情还是实际上是一种方法)是:

  1. 从 Arduino 拔下 USB
  2. 按住重置按钮
  3. 插入 USB 并开机
  4. 继续保存并上传草图。上传完成后,松开重置按钮。

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) was:

  1. Unplug USB from the Arduino
  2. Press and hold the reset button
  3. Plug in USB and power up
  4. Continue holding and upload the sketch. Once it's done uploading, release the reset button.
冰雪梦之恋 2024-10-28 20:53:02

我今天也遇到了同样的问题。我们找到了一个简单的解决方案来解决这个问题(感谢 Anghiara):

不要使用屏幕上的“上传按钮”(带有绿色箭头的圆圈)将新代码加载到 Arduino,而是使用鼠标单击“草图”,然后“上传”。

使用 Serial.println() 和循环。我通过惨痛的教训吸取了教训。

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 code 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 code when working with Serial.println() and loops. I learned my lesson the hard way.

莫言歌 2024-10-28 20:53:02

如果端口显示已使用,那么您可能使用了错误的端口。

将其切换到您连接 Arduino 的端口,然后尝试重新上传,您一定会看到它工作。

If the port says Already used, then you are probably using the wrong port.

Switch it to the port where you connected your Arduino and then try to re-upload, you will definitely see it work.

情归归情 2024-10-28 20:53:02
  1. 从微控制器拔下 Tx
  2. 插入 USB 电缆
  3. 等待满载
  4. 将 Rx 连接到硬件
  5. 在程序中编译空草图并断开连接 tx(不用担心错误)
  6. 将 Rx 与硬件
  7. 连接 编译空草图
  8. 关闭电源并连接 Tx
  1. Unplug Tx from the microcontroller
  2. Insert USB cable
  3. Wait until full load
  4. Connect Rx with hardware
  5. Compile empty sketch in prosses and unconnect tx (don't worry about the error)
  6. Connect Rx with hardware
  7. Compile empty sketch
  8. Power off and connect Tx
星星的轨迹 2024-10-28 20:53:02

确保您没有从终端访问串行端口。该循环(或任何代码)不应阻止 Arduino 的编程。

Be sure you are not accessing the serial port from a terminal. That loop (or any code) should not prevent the Arduino from being programmed.

断舍离 2024-10-28 20:53:02

我遇到了类似的问题。

如果我打开 Arduino 电源,上传的程序执行之前会出现延迟。

所以我利用这个延迟来上传新程序或空程序:

void setup(){}

void loop(){}

所以我的问题解决了。

上传之前请拔下与 Arduino 引脚的所有连接。

I got a similar problem.

If I power on my Arduino, there is a delay before the uploaded program execute.

So I use that delay for uploading new program, or empty program:

void setup(){}

void loop(){}

So my problem was solved.

Unplug any connection to Arduino pins before upload.

鹤舞 2024-10-28 20:53:02

如果没有任何帮助,那么您应该再安排一块板,并尝试通过 Arduino as ISP 选项将其刷新,如 Arduino 作为 ISP 和 Arduino Bootloader从 Arduino 到面包板上的微控制器

您可以选择自己的程序通过 ISP 进行闪存,而不是引导加载程序。

If nothing helped then you should arrange one more board and try to flash it through the Arduino as ISP option as shown in Arduino as ISP and Arduino Bootloaders or From Arduino to a Microcontroller on a Breadboard.

Instead of a boot loader, you can select your own programs to flash via ISP.

月棠 2024-10-28 20:53:02

对于 arduino nano 33 iot 对我有用的唯一方法是连续多次按下板上的重置按钮,然后按 uoplad!

The only way it worked for me for arduino nano 33 iot is via pressing the reset button on the board continuously many time then press uoplad!

奢欲 2024-10-28 20:53:02

如果您尝试通过 USB 电缆进行编程,以下是最佳方法:

  1. 将板上的 Tx 信号接地(连接数字 I/O #1 至 GND)
  2. 插入 USB 线
  3. 上传新程序
  4. 拔下 USB 线
  5. 移除 Tx 接地

您已准备就绪!

Here is the best way that works out if you are trying to program through the USB cable:

  1. Ground the Tx signal on the board (connect digital I/O #1 to GND)
  2. Plug the USB cable
  3. Upload a new program
  4. Remove the USB cable
  5. Remove Tx grounding

You are all set!

梨涡少年 2024-10-28 20:53:02

我也遇到了你的问题,我使用以下步骤解决了这个问题(尽管你可能已经解决了这个问题,它只是分享给访问此页面的任何人):

  1. 拔下你的 Arduino
  2. 准备一个空的设置和空的循环程序
  3. 写一个注释符号程序末尾的“//”
  4. 将键盘指针设置在“//”符号旁边
  5. 将 Arduino 插入计算机,等到 Arduino 完全引导加载,它将输出“Hello, World!”
  6. 您将看到“你好,世界!”输出脚本将显示为注释,因此您可以安全地单击上传

I also had your problem,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):

  1. Unplug your Arduino
  2. Prepare an empty setup and empty loop program
  3. Write a comment symbol '//' at the end of program
  4. Set your keyboard pointer next to the '//'symbol
  5. Plug your Arduino into the computer, wait until the Arduino is completely bootloaded and it will output 'Hello, World!'
  6. You will see the 'Hello, World!' outputting script will be shown as comment, so you can click Upload safely.
从来不烧饼 2024-10-28 20:53:02
  1. 首先,连接您的 Arduino 设备。
  2. 然后转到设备管理器并卸载驱动程序。
  3. 现在移除您的 Arduino 设备。
  4. 再次将 Arduino 设备连接到系统。
  5. 现在安装您的驱动程序(您之前已卸载)。

它肯定会释放你的端口。

  1. First of all, connect your Arduino device.
  2. Then go to Device Manager and uninstall the driver.
  3. Now remove your Arduino device.
  4. Again connect you Arduino device to your system.
  5. Now install your driver (which you have uninstalled earlier).

It will free your port for sure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文