// **************************************************** // Melodien aus PROGMEM vom 27. 09. 2025 // **************************************************** const PROGMEM char title[] = { // List of text for melody-titles new 30.06.2025 - change number_mel too! "Asa Branca " // 1 Asa Branca 0 text-length 14 all titles full length "Take on me " // 2 Take on me "Starwars " // 3 Starwars "Cantina-Band " // 4 Cantina-Band "Game of Throne" // 5 Game of Thrones "Fuer Elise " // 6 Für Elise "Greensleeves " // 7 Greensleeves "Silent Night " // 8 Silent Night "Happy Birthday" // 9 Happy Birthday "Nokia Ringtone" // 10 Nokia Ringtone "Pacman " // 11 Pacman "Super-Mario " // 12 Super-Mario "Tetris " // 13 Tetris "Imperial March" // 14 Imperial March "Zelda " // 15 Zelda "Ode of Joy " // 16 Ode of Joy "Pink Panther " // 17 Pink Panther "Lullaby " // 18 Lullaby (Brahms Wiegenlied) "Keyboard Cat " // 19 Keyboard cat "MII Channel " // 20 MII Channel "Greenhill " // 21 Greenhill "Song of Storms" // 22 Song of storms "Minuet in G " // 23 Minuet in G "Pulo da gaita " // 24 Pulo da gaita "Badinerie " // 25 Badinerie "Baby elephant " // 26 Empty "Cannon in D " // 27 Cannon in D "No data " // 28 Empty "No data " // 29 Empty "No data " // 30 Empty "No data " // 31 Empty "No data " // 32 Empty "No data " // 33 Empty "No data " // 34 Empty "No data " // 35 Empty "No data " // 36 Empty "No data " // 37 Empty "No data " // 38 Empty "No data " // 39 Empty "No data " // 40 Empty "No data " // 41 Empty "No data " // 42 Empty "No data " // 43 Empty "No data " // 44 Empty "No data " // 45 Empty "No data " // 46 Empty "No data " // 47 Empty "No data " // 48 Empty }; const PROGMEM int tempis[] = { // Tempi for songs 120,140,108,140,85,80,70,140,140,140, // Values Song 1 - 10 Asa Branca, Take on me, Starwars,Cantina Band, Game of thrones, Fuer Elise, Greensleeves Silent night, Happy birthday, Nokia Ringtone 105,200,144,120,114,88,120,76,160,114, // 11 - 20 Pacman, Super Mario, Tetris,Imperial, Zelda, Ode of Joy, Pink Panther, Lullaby, Keyboard cat, MII Channel 140,108,140,100,120,132,100,99,99,99, // 21 - 30 Greenhill, Song of storms, minuet in G,Pulo da gaita, Badinerie, Baby epelpaht walk, Cannon in D 99,99,99,99,99,99,99,99,99,99, // 31 - 40 99,99,99,99,99,99,99,99,99,99 // 41 - 50 }; #define BUZZER 8 // Buzzer-Pin #define REST 0 // Pause between notes #include "pitches.h" // Pitches for notes #include "melody.h" // Notes for melody byte snd = 0; // Music title number int tempo = 150; // Tempo old 180 int ofset = 0; // Offset between melodies int note = 0; // Current note byte length = 50; // Length of melodies char myChar = '-'; // Character for song title void setup() { // put your setup code here, to run once: Serial.begin(19200); // opens serial port, sets data rate to 9600 / 19200 / 38400 / 57600 / 115200 bps //int tempo = 120; // change this to make the song slower or faster //int buzzer = 11; // change this to whichever pin you want to use //int notes = sizeof(melody) / sizeof(melody[0]) / 2; // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) int divider = 0, noteDuration = 0; // int notes = 100; int wholenote = 0; // for (snd = 1; snd < 28;snd++){ // Play melody 1 - 27 tempo = pgm_read_word_near(tempis+(snd-1)); // Melody tempo for this melody from flash Serial.print("Title: "); ;Serial.print(snd); // Print title no + text Serial.print(" "); // Blank for (byte x=0; x <14; x++){ // For 15 chars myChar=pgm_read_word_near(title+(snd-1)*14+x); // Get title text from flash Serial.print(myChar);} // Print char to lcd Serial.print(" tempo: ");Serial.println(tempo); // Print tempo wholenote = (60000 * 4) / tempo; // Calculate the duration of a whole note in ms //for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { // iterate over the notes of the melody. length is 200 bytes for (int thisNote=0;thisNote 0) { // regular note, just proceed noteDuration = (wholenote) / divider; } // Calculate regular note duration else if (divider < 0) { // dotted notes are represented with negative durations!! noteDuration = (wholenote) / abs(divider); // Calculate dotted note duration noteDuration *= 1.5; } // increases the duration in half for dotted notes // tone(BUZZER, melody[thisNote], noteDuration * 0.9); // we only play the note for 90% of the duration, leaving 10% as a pause tone(BUZZER, pgm_read_word_near(melody+ofset+thisNote), noteDuration * 0.9); // we only play the note for 90% of the duration, leaving 10% as a pause delay(noteDuration); // Wait for the specified duration before playing the next note. noTone(BUZZER); // stop the waveform generation before the next note. } } } void loop() { // put your main code here, to run repeatedly: }