简体   繁体   English

如何为 Arduino Due 实现tone() 和 noTone()?

[英]How do I implement tone() and noTone() for the Arduino Due?

As it turns out, noTone() and tone() are in the core arduino API, but seemingly not implemented for the Arduino Due .事实证明, noTone()tone()在核心 arduino API 中,但似乎没有Arduino Due实现。 I was hoping to use tone() and noTone() to implement the mario death sound found here, but when I add the code and compile it, I get the following errors:我希望使用tone()noTone()来实现这里找到的马里奥死亡声音,但是当我添加代码并编译它时,我得到以下错误:

 trenchRun:154: error: 'tone' was not declared in this scope trenchRun:156: error: 'noTone' was not declared in this scope

In case you're interested, here's an SSCCE, compiled against Arduino 1.5.4 on Mac OS X 10.8:如果您有兴趣,这里有一个 SSCCE,在 Mac OS X 10.8 上针对 Arduino 1.5.4 编译:

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  tone(1, 12345, 1000);
}
 sketch_oct24a.ino: In function 'void loop()': sketch_oct24a:7: error: 'tone' was not declared in this scope

Since I have an Arduino Due, I am limited in using Arduino 1.5.4.因为我有一个 Arduino Due,所以我只能使用 Arduino 1.5.4。

How do I implement the tone() and noTone() functions for the Due?如何为 Due 实现tone()noTone()函数?

Yes it seems that it is still disabled in the current version.是的,它似乎在当前版本中仍然被禁用。

A quick search on the Arduino forum got me this : Arduino Due and tone() I can't test their code but it seems that the guy found a pretty decent solution to make his own tone() .在 Arduino 论坛上快速搜索得到了这个: Arduino Due 和tone()我无法测试他们的代码,但似乎这家伙找到了一个相当不错的解决方案来制作自己的tone()

Have a look and tell us if it's working good.看看并告诉我们它是否运作良好。

Hope it helps!希望能帮助到你! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM