arduino-volume1
arduino-volume1 copied to clipboard
Unexpected results using noTone()
The standard arduino tone() function allows a third parameter 'duration'.
As this is absent in the volume.tone(), I thought I'd use a delay followed by the volume.noTone() command.
Example:
#include <Volume.h>
Volume vol;
void setup() {
vol.begin();
}
void loop() {
vol.tone(900, 255);
vol.delay(500);
vol.noTone();
vol.delay(500);
}
I thought this would turn the buzzer on for a half a second then turn it off for half a second and keep repeating, however, it just results in complete silence (Arduino Nano).
Very strangely though, the following code works perfectly!?!?!
#include <Volume.h>
Volume vol;
void setup() {
vol.begin();
Serial.begin(9600);
}
void loop() {
vol.tone(900, 255);
Serial.println("Tone");
vol.delay(500);
vol.noTone();
Serial.println("No Tone");
vol.delay(500);
}
And this works:
#include <Volume.h>
Volume vol;
void setup() {
vol.begin();
Serial.begin(9600);
}
void loop() {
vol.tone(900, 255);
Serial.println("Tone");
vol.delay(500);
vol.noTone();
/* Serial.println("No Tone"); */
vol.delay(500);
}
But this doesn't...
#include <Volume.h>
Volume vol;
void setup() {
vol.begin();
Serial.begin(9600);
}
void loop() {
vol.tone(900, 255);
/* Serial.println("Tone"); */
vol.delay(500);
vol.noTone();
Serial.println("No Tone");
vol.delay(500);
}