Přidání zvuku do bzučáku
This commit is contained in:
+11
-6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user