|
Serial Musical Organ 1.0
Buzzer controller and musical organ
|
Pre-defined songs for musical organ. More...

Go to the source code of this file.
Functions | |
| void | play_twinkle_little_star () |
| Plays "Twinkle Twinkle Little Star" melody. | |
| void | play_imperial_march () |
| Plays "Imperial March" (Darth Vader's Theme) from Star Wars. | |
Pre-defined songs for musical organ.
Declares functions to play pre-programmed songs via USART commands. Songs are triggered by numeric keys (e.g., '1' for Twinkle Star, '2' for Imperial March).
| Key | Function | Song Title | Duration |
|---|---|---|---|
| '1' | play_twinkle_little_star() | Twinkle Twinkle Little Star | ~10-15 sec |
| '2' | play_imperial_march() | Imperial March (Star Wars) | ~30 sec |
Definition in file pre_defined_songs.h.
| void play_imperial_march | ( | ) |
Plays "Imperial March" (Darth Vader's Theme) from Star Wars.
Blocking function that plays the iconic Imperial March theme composed by John Williams for Star Wars: The Empire Strikes Back (1980). Associated with Darth Vader and the Galactic Empire.
The piece follows this structure:
* Intro (4 bars) | Main Theme A (4 bars) | Main Theme B (4 bars) | * Bridge (4 bars) | Main Theme A (4 bars) | Build-up (3 bars) | * Climax (5 bars) | Resolution (4 bars) | Coda (6 bars) *
* G3 - G3 - G3 - (G3 D#3) G3 | G3 G3 G3 D#3 G3 | * C4 C4 C4 G3 C4 | A#3 A#3 A#3 F3 A#3 | * [Pattern repeats with variations] *
Implement non-blocking version using timer interrupts
Add ability to stop playback mid-song (emergency stop)
Referenced by main().

| void play_twinkle_little_star | ( | ) |
Plays "Twinkle Twinkle Little Star" melody.
Blocking function that plays the classic children's song "Twinkle Twinkle Little Star" through the buzzer.
* CC GG AA G - FF EE DD C - GG FF EE D - GG FF EE D - * CC GG AA G - FF EE DD C *
Implements the complete Twinkle Twinkle Little Star song using fixed note durations (Q=250ms for eighth notes, H=500ms for quarter notes). The song has 42 notes organized in 6 phrases of 7 notes each.
* Phrase 1: C4 C4 G4 G4 A4 A4 G4 (Twinkle twinkle little star) * Phrase 2: F4 F4 E4 E4 D4 D4 C4 (How I wonder what you are) * Phrase 3: G4 G4 F4 F4 E4 E4 D4 (Up above the world so high) * Phrase 4: G4 G4 F4 F4 E4 E4 D4 (Like a diamond in the sky) * Phrase 5: C4 C4 G4 G4 A4 A4 G4 (Twinkle twinkle little star) * Phrase 6: F4 F4 E4 E4 D4 D4 C4 (How I wonder what you are) *
| Note | Frequency (Hz) | Period (μs) | Timer Value |
|---|---|---|---|
| C4 | 261.63 | 3822 | 1911 |
| D4 | 293.66 | 3405 | 1702 |
| E4 | 329.63 | 3033 | 1516 |
| F4 | 349.23 | 2863 | 1431 |
| G4 | 392.00 | 2551 | 1275 |
| A4 | 440.00 | 2272 | 1136 |
@complexity O(n) where n = 42 notes @performance Takes ~10-15 seconds to complete (Q=250ms, H=500ms)
Array of notes for Twinkle Twinkle Little Star
Contains 42 note frequency values in sequence. Values correspond to C4, G4, A4, F4, E4, D4 from scale16.h.
Array of durations for Twinkle Twinkle Little Star
Each duration corresponds to the note at the same index in estrellita_notas[]. Uses Q (250ms) for short notes and H (500ms) for notes that should be held longer.
Play each note in sequence
Iterates through all 42 notes and plays each with its corresponding duration. The loop is blocking.
Definition at line 82 of file pre_defined_songs.c.
References A4, C4, D4, E4, F4, G4, H, playNote(), and Q.
Referenced by main().

