For what it is worth, for some programs in the past, before tone I had a quick and dirty version of sound output, that did what I needed, like to let me know the robot got the last command from the remote...
Also I found tone did not work very well for multiple notes.
Again this is nothing special...
Code:
void SoundNoTimer(unsigned long duration, unsigned int frequency)
{
// The tone command does sort of work, but does not play multiple sounds smoothly
// tone(SOUND_PIN, frequency, duration); // Try the arduino library
// delay(duration);
pinMode(SOUND_PIN, OUTPUT);
digitalWrite(SOUND_PIN, LOW);
toggle_count = 2 * frequency * duration / 1000;
lusDelayPerHalfCycle = 1000000L/(frequency * 2);
// if we are using an 8 bit timer, scan through prescalars to find the best fit
while (toggle_count--) {
// toggle the pin
fHigh = !fHigh;
digitalWrite(SOUND_PIN, fHigh? LOW : HIGH);
// delay a half cycle
delayMicroseconds(lusDelayPerHalfCycle);
}
digitalWrite(SOUND_PIN, LOW);
}
void MSound(byte cNotes, ...)
{
va_list ap;
unsigned int uDur;
unsigned int uFreq;
va_start(ap, cNotes);
while (cNotes > 0) {
uDur = va_arg(ap, unsigned int);
uFreq = va_arg(ap, unsigned int);
SoundNoTimer(uDur, uFreq);
cNotes--;
}
va_end(ap);
}
But for example with with the hexapod, I would have sounds in like:
Startup: MSound(3, 60, 2000, 80, 2250, 100, 2500);
Shutdown: MSound(3, 100, 2500, 80, 2250, 60, 2000);
Command received: MSound( 1, 50, 2000);
Command options cycled back to first: MSound( 2, 50, 2000, 50, 3000);
But again maybe for simple timed beep with pause, just use tone as you mentioned not blocking...