I might have a simple and stupid problem, but I can't solve it. Could somebody explain me why this happens? I just want to make the Arduino play a song through the passive buzzer. But when I execute the following code:
I get this error:
error: expected ';' before numeric constant
The IDE somehow needs an ';' before the delay numeric.
Everything else is fine, I can execute the code without delay. But everytime I try to add a delay in order to add another follow-up tone, it doesn't work.
takes 1 sec to be executed? Somehow the two timespans start at the same time while I would rather have them to be processed one after another. So first 0.5 secs of tone and then 1 sec delay. Why isn't this the case?
If you provide no duration to tone() it plays forever until you send a noTone(). So how likely is it that tone() is a blocking command that stops execution until it completes?
slipstick:
If you provide no duration to tone() it plays forever until you send a noTone(). So how likely is it that tone() is a blocking command that stops execution until it completes?
I believe it is unlikely. The following snippet, which lacks a duration argument, plays a variable frequency tone until cancelled elsewhere by notone().
Since a number of other things are happening to modulate the frequency I conclude that tone() is not a blocking function.
/*
Generate tone of varying pitch based on ram distance reading.
Pitch increases as ram nears the load position,
*/
void toneRamp() { // parmVal sets slope of frequency change
if (rangeToRam_mm < textAndParms[menuSetRangeLoad].parmVal * 3) {
tone(piezo, 500 - rangeToRam_mm * textAndParms[menuBuzzer].parmVal);
}
}