Přidání zvuku do bzučáku

This commit is contained in:
Matěj Kubíček
2026-06-08 09:49:49 +02:00
parent 18db6b24da
commit f2ba4556c8
+11 -6
View File
@@ -2,7 +2,6 @@
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <EEPROM.h>
// piny
constexpr byte ENCODER_CLK_PIN = 11; // pwm pin, ale nepoužívá se
@@ -38,14 +37,20 @@ void CloseLock() {
// chování bzučáku
void OpenSound() {
// TODO: melodie při otevření
int melody[] = { 262, 330, 392, 523 }; // C4, E4, G4, C5
int durations[] = { 150, 150, 150, 300 };
for (int i = 0; i < 4; i++) {
tone(BUZZER_PIN, melody[i], durations[i]);
delay(durations[i] + 30);
}
noTone(BUZZER_PIN);
}
void CloseSound() {
// TODO: ověřit tento zvuk
digitalWrite(BUZZER_PIN, HIGH);
delay(100);
digitalWrite(BUZZER_PIN, LOW);
tone(BUZZER_PIN, 262, 150);
delay(500);
noTone(BUZZER_PIN);
}
// chování RGB LED