// פינים
#define BUTTON_UP 12
#define BUTTON_DOWN 14
#define BUTTON_SELECT 27
#define BUZZER_PIN 25
#define MENU_SIZE 5
const char *menu[MENU_SIZE] = {
"Morning Bell Melody", // File 1
"Happy Birdsong Melody", // File 2
"Settings",
"About",
"Exit"
};
int cursor = 0;
void setup() {
Serial.begin(115200);
pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
pinMode(BUTTON_SELECT, INPUT_PULLUP);
pinMode(BUZZER_PIN, OUTPUT);
showMenu();
}
void loop() {
if (digitalRead(BUTTON_UP) == LOW) {
delay(200);
cursor = (cursor - 1 + MENU_SIZE) % MENU_SIZE;
showMenu();
}
if (digitalRead(BUTTON_DOWN) == LOW) {
delay(200);
cursor = (cursor + 1) % MENU_SIZE;
showMenu();
}
if (digitalRead(BUTTON_SELECT) == LOW) {
delay(200);
Serial.print("✅ Selected: ");
Serial.println(menu[cursor]);
if (cursor == 0) {
Serial.println("🎵 Playing: Morning Bell...");
playMorningBell();
} else if (cursor == 1) {
Serial.println("🐦 Playing: Happy Birdsong...");
playHappyBirdsong();
} else if (cursor == 2) {
Serial.println("🔧 Opening settings...");
} else if (cursor == 3) {
Serial.println("ℹ️ About: Waking up with code ☀️");
} else if (cursor == 4) {
Serial.println("👋 Exiting...");
}
}
}
void showMenu() {
Serial.println("\n==== MENU ====");
for (int i = 0; i < MENU_SIZE; i++) {
if (i == cursor) Serial.print("> ");
else Serial.print(" ");
Serial.println(menu[i]);
}
}
// ☀️ Morning Bell Melody
void playMorningBell() {
int melody[] = { 880, 988, 1046, 1318, 1174, 988, 880 }; // תווים נעימים
int durations[] = { 300, 300, 300, 500, 300, 300, 400 };
for (int i = 0; i < 7; i++) {
tone(BUZZER_PIN, melody[i]);
delay(durations[i]);
noTone(BUZZER_PIN);
delay(100);
}
}
// 🐦 Happy Birdsong Melody
void playHappyBirdsong() {
int notes[] = { 1600, 1800, 2000, 1800, 2200, 1800, 1600 };
int delays[] = { 100, 100, 120, 80, 150, 100, 100 };
for (int i = 0; i < 7; i++) {
tone(BUZZER_PIN, notes[i]);
delay(delays[i]);
noTone(BUZZER_PIN);
delay(60);
}
delay(250);
// צליל סיום מתוק
tone(BUZZER_PIN, 2500);
delay(200);
noTone(BUZZER_PIN);
}