We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 15b8180 commit 262c00fCopy full SHA for 262c00f
KY006_Buzzer/KY006_Buzzer.cpp
@@ -12,10 +12,17 @@ KY006_Buzzer::KY006_Buzzer(int buzzer_pin) {
12
}
13
14
void KY006_Buzzer::begin() {
15
+ pinMode(_buzzerPin, OUTPUT);
16
17
-void KY006_Buzzer::enable() {
18
+void KY006_Buzzer::enable(unsigned int frequency, unsigned long duration) {
19
+ // stop sound first
20
+ disable();
21
+
22
+ // start sound
23
+ tone(_buzzerPin, frequency, duration);
24
25
26
void KY006_Buzzer::disable() {
27
+ noTone(_buzzerPin);
28
KY006_Buzzer/KY006_Buzzer.h
@@ -16,7 +16,7 @@ class KY006_Buzzer
int buzzer_pin
);
void begin();
- void enable();
+ void enable(unsigned int frequency = 1000, unsigned long duration = 100);
void disable();
private:
0 commit comments