arduino 复位-ag捕鱼王app官网

arduino 复位

作者:迹忆客 最近更新:2024/03/13 浏览次数:

本教程将讨论三种复位 arduino 的方法。第一种方法是 arduino 上的复位按钮。第二种方法是 softwarereset 库,第三种是 adafruit 的 sleepydog 库。


使用复位按钮复位 arduino

如果你使用的是 linux,则存在一个错误,该错误会阻止 arduino ide 与 arduino 开发板对话。结果,你无法在 arduino 中上传代码,它将给出一个错误。在这种情况下,你可以使用此方法复位 arduino。

首先,请确保没有集线器将 arduino 直接连接到计算机。使用集线器有时会给你带来错误。现在关闭 arduino 的电源,按住复位按钮,同时再次打开它的电源。这将复位你的 arduino,并且你可以轻松上传其他代码而不会出现任何错误。


使用 softwarereset 库复位 arduino

如果你想使用 sketch 复位 arduino,则可以使用 softwarereset 库轻松复位。该库与 avr 架构兼容,因此你可以将其与 arduino uno、mega、yun、nano 和 leonardo 开发板一起使用。要使用此库,你需要使用 arduino ide 中提供的库管理器进行安装。

该库有两种复位 arduino 的方法。一种是 standard 方法,该方法将使用看门狗计时器复位 arduino。另一种方法是 simple 方法,该方法将仅重新启动程序。

void loop() {
  // all of your code
  softwarereset::standard();  // reset using the standard method
  softwarereset::simple();    // restart the program
}

请注意,将不会执行在复位代码下方写入的任何代码行。因此,请确保在完成代码后使用 reset。有关更多信息,请阅读库文档。


使用 adafruit sleepydog 库复位 arduino

上面的库仅适用于五个 arduino 开发板。如果你的 arduino 不是其中之一,那么你可以使用此库,因为它支持几乎所有的 arduino 开发板。使用此链接检查 arduino 是否与此库兼容。

#include 
void setup() {
  // make sure to reset the watchdog before the countdown expires or
  // the arduino will reset!
  int countdownms = watchdog.enable(4000);
}
void loop() {
  // all of your code
}

在上面的代码中,arduino 将在 4 秒钟内复位。你可以使用复位方法复位看门狗。有关更多信息,请阅读库文档。

上一篇:

下一篇:arduino 中停止循环

转载请发邮件至 1244347461@qq.com 进行申请,经作者同意之后,转载请以链接形式注明出处

本文地址:

相关文章

arduino 中停止循环

发布时间:2024/03/13 浏览次数:444 分类:c

可以使用 exit(0),无限循环和 sleep_n0m1 库在 arduino 中停止循环。

发布时间:2024/03/13 浏览次数:181 分类:c

可以使用简单的方法 toint()函数和 serial.parseint()函数将 char 转换为 int。

arduino 串口打印多个变量

发布时间:2024/03/13 浏览次数:381 分类:c

可以使用 serial.print()和 serial.println()函数在串口监视器上显示变量值。

arduino if 语句

发布时间:2024/03/13 浏览次数:123 分类:c

可以使用 if 语句检查 arduino 中的不同条件。

arduino icsp

发布时间:2024/03/13 浏览次数:214 分类:c

icsp 引脚用于两个 arduino 之间的通信以及对 arduino 引导加载程序进行编程。

发布时间:2024/03/13 浏览次数:151 分类:c

可以使用 arduino 中的循环制作计数器。

使用 c 编程 arduino

发布时间:2024/03/13 浏览次数:127 分类:c

本教程将讨论使用 arduino ide 在 c 中对 arduino 进行编程。

arduino 中的子程序

发布时间:2024/03/13 浏览次数:168 分类:c

可以通过在 arduino 中声明函数来处理子程序。

arduino printf 函数

发布时间:2024/03/13 浏览次数:223 分类:c

通过使用 sprintf()函数和 serial.print()函数,可以获得与 printf()相同的输出。

扫一扫阅读全部技术教程

社交账号
  • https://www.github.com/onmpw
  • qq:1244347461

最新推荐

教程更新

热门标签

扫码一下
查看教程更方便
网站地图