Buzzer: Improve buzzes
parent
a4f9e1b55e
commit
8eae11c530
|
@ -2,19 +2,12 @@
|
|||
#include "constants.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
void buzzOff() {
|
||||
noTone(BUZZER_PIN);
|
||||
pinMode(BUZZER_PIN, INPUT);
|
||||
}
|
||||
|
||||
void helloBuzz() {
|
||||
tone(BUZZER_PIN, 500, 100);
|
||||
delay(100);
|
||||
tone(BUZZER_PIN, 1000, 100);
|
||||
delay(100);
|
||||
tone(BUZZER_PIN, 4000, 100);
|
||||
delay(100);
|
||||
buzzOff();
|
||||
}
|
||||
|
||||
void happyBuzz() {
|
||||
|
@ -22,23 +15,18 @@ void happyBuzz() {
|
|||
delay(75);
|
||||
tone(BUZZER_PIN, 2000, 100);
|
||||
delay(100);
|
||||
buzzOff();
|
||||
}
|
||||
|
||||
void sadBuzz() {
|
||||
tone(BUZZER_PIN, 330, 250);
|
||||
delay(300);
|
||||
tone(BUZZER_PIN, 311, 250);
|
||||
delay(250);
|
||||
buzzOff();
|
||||
}
|
||||
|
||||
void beep() {
|
||||
tone(BUZZER_PIN, 1000, 50);
|
||||
delay(50);
|
||||
buzzOff();
|
||||
}
|
||||
|
||||
void tick() {
|
||||
tone(BUZZER_PIN, 200, 5);
|
||||
tone(BUZZER_PIN, 200, 10);
|
||||
}
|
||||
|
|
|
@ -4,5 +4,4 @@ void helloBuzz();
|
|||
void happyBuzz();
|
||||
void sadBuzz();
|
||||
void beep();
|
||||
void buzzOff();
|
||||
void tick();
|
||||
|
|
|
@ -26,8 +26,6 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
// tick();
|
||||
|
||||
// debugScanI2C();
|
||||
// demoScreen();
|
||||
// demoStepper();
|
||||
|
@ -36,7 +34,6 @@ void loop() {
|
|||
|
||||
auto key = handleKeyboard();
|
||||
if (key != KEY_NONE) {
|
||||
tick();
|
||||
Serial.print("Key pressed: ");
|
||||
Serial.print(allKeys[key]);
|
||||
|
||||
|
@ -49,6 +46,18 @@ void loop() {
|
|||
}
|
||||
|
||||
Serial.println();
|
||||
|
||||
if (key == KEY_A) {
|
||||
happyBuzz();
|
||||
} else if (key == KEY_B) {
|
||||
sadBuzz();
|
||||
} else if (key == KEY_C) {
|
||||
beep();
|
||||
} else if (key == KEY_D) {
|
||||
tick();
|
||||
} else {
|
||||
tick();
|
||||
}
|
||||
}
|
||||
|
||||
if (auto event = handleSwitch()) {
|
||||
|
|
Loading…
Reference in New Issue