极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8670|回复: 2

請問如何解決 IRremote 與 tone 衝突

[复制链接]
发表于 2014-3-9 15:04:35 | 显示全部楼层 |阅读模式
我在這裡下載Library https://github.com/coopermaa/Arduino-IRremote

上載程式時會出現下列訊息:
core.a(Tone.cpp.o): In function `__vector_7':
D:\arduino-1.0.5\hardware\arduino\cores\arduino/Tone.cpp:535: multiple definition of `__vector_7'
IRremote\IRremote.cpp.o:\arduino-1.0.5\libraries\IRremote/IRremote.cpp:311: first defined here

我大概知道是 IRremote 和 tone() 都使用 Timer 2, 所以才會衝突, 請問該如何解決。

源碼如下:
  1. #include <IRremote.h>

  2. void setup()
  3. {
  4. tone(11, 1140, 200);
  5. }

  6. void loop()
  7. {
  8. }
复制代码
回复

使用道具 举报

发表于 2014-3-9 15:37:14 | 显示全部楼层
在tone后面要跟一个和tone一样长时间的delay,因为执行了tone以后会继续执行后面的代码,加个delay让tone完事了再继续。应该就不会冲突了。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-3-9 16:49:32 | 显示全部楼层
本帖最后由 pizg 于 2014-3-9 16:51 编辑
shihaipeng04 发表于 2014-3-9 15:37
在tone后面要跟一个和tone一样长时间的delay,因为执行了tone以后会继续执行后面的代码,加个delay让tone完 ...


你說的方法還是不行!

  1. #include <IRremote.h>

  2. void setup()
  3. {
  4. tone(11, 1140, 200);
  5. delay(200);
  6. }

  7. void loop()
  8. {
  9. }
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-24 07:49 , Processed in 0.040876 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表