Thomas Stegh
Published © CC BY

I Love You Für Elise

Displays a heart and "I love you!" while playing "Für Elise" and randomly blinks an RGB LED.

BeginnerShowcase (no instructions)1 hour1,340
I Love You Für Elise

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1

Story

Read more

Schematics

schematics_1860x1395_4EQ01H05lU.png

Code

I love you für Elise

JavaScript
let AktuelleNote = ""
let Start = 0
let Musik = ""
let Herz: Image = null
basic.forever(() => {
    Musik = "E4_,D4#,E4_,D4#,E4_,B3_,D4_,C4_,A3_,E3_,A3_,C3_,E3_,A3_,B3_,E3_,G3#,E3_,G3#,B3_,C4_,E3_,A3_,E3_"
    music.setTempo(200)
    Start = 0
    while (Start <= Musik.length) {
        AktuelleNote = Musik.substr(Start, 3)
        Start += 4
        if (AktuelleNote == "A3_") {
            music.playTone(Note.A3, music.beat(BeatFraction.Quarter))
        } else {
            if (AktuelleNote == "B3_") {
                music.playTone(Note.B3, music.beat(BeatFraction.Quarter))
            } else {
                if (AktuelleNote == "C3_") {
                    music.playTone(Note.C3, music.beat(BeatFraction.Quarter))
                } else {
                    if (AktuelleNote == "E3_") {
                        music.playTone(Note.E3, music.beat(BeatFraction.Quarter))
                    } else {
                        if (AktuelleNote == "C4_") {
                            music.playTone(Note.C4, music.beat(BeatFraction.Quarter))
                        } else {
                            if (AktuelleNote == "D4_") {
                                music.playTone(Note.D4, music.beat(BeatFraction.Quarter))
                            } else {
                                if (AktuelleNote == "E4_") {
                                    music.playTone(Note.E4, music.beat(BeatFraction.Quarter))
                                } else {
                                    if (AktuelleNote == "D4#") {
                                        music.playTone(Note.D4, music.beat(BeatFraction.Quarter))
                                    } else {
                                        if (AktuelleNote == "G3#") {
                                            music.playTone(Note.GSharp3, music.beat(BeatFraction.Quarter))
                                        } else {

                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        basic.setLedColor(basic.rgbw(
            Math.random(256),
            Math.random(256),
            Math.random(256),
            0
        ))
        music.rest(music.beat(BeatFraction.Quarter))
    }
})
Herz = images.createImage(`
    . # . # .
    # # # # #
    # # # # #
    . # # # .
    . . # . .
    `)
Herz.showImage(0)
basic.pause(1000)
basic.showString(" I love you!")
while (true) {
    Herz.showImage(0)
    basic.pause(50)
    basic.clearScreen()
    basic.pause(50)
}

Credits

Thomas Stegh

Thomas Stegh

2 projects • 4 followers
Father of four. Developer for eTASK CAFM Computer-aided facility management. BIM, IFC, buildingSMART, Revit, SVG, HoloLens, SQL Server, Crystal Reports, AutoCAD

Comments