Buzzer: Improve buzzes

main
radex 2024-02-14 17:24:55 +01:00
parent a4f9e1b55e
commit 8eae11c530
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
3 changed files with 13 additions and 17 deletions

View File

@ -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);
}

View File

@ -4,5 +4,4 @@ void helloBuzz();
void happyBuzz();
void sadBuzz();
void beep();
void buzzOff();
void tick();

View File

@ -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()) {