只需用这段代码来检查音调和noTone的音效如何,但根本无法停止声音。当noTone命令触发时,我们只是改变了声音,但它仍然存在。 这个小代码有什么问题? 我在arduino mega上尝试过。
void setup()
{
}
void loop()
{
tone(A5, 100); // first tone
delay(1000);
noTone(A5); // This causes the first tone to stop
tone(A5, 200); //The second tone with the pitch “200” starts
delay(1000); //for one second
noTone(A5); //With this line the second tone stops and the loop starts over
delay(2000);
}