Merry Christmas & Jingle Bells am Calliope Mini


#1

Hallo,

hier ein Projekt für nächstes Weihnachten.

Button A: Jingle Bells (danke an das Forum für diesen Part)
Button B: We Wish You A Merry Christmas
LED-Animation dazu :sunglasses:

Extrafeature: Wenn der Calliope am Christbaum hängt und über 50°C erreicht, dann brennt der Christbaum und es ertönt ein Alarm. :fire:

let var_knopf = 0
let var_durchgaenge = 0
input.onButtonPressed(Button.AB, () => {
    var_knopf = 0
})
input.onButtonPressed(Button.A, () => {
    if (var_knopf == 0) {
        var_knopf = 1
    }
})
input.onButtonPressed(Button.B, () => {
    if (var_knopf == 0) {
        var_knopf = 2
    }
})
input.onGesture(Gesture.Shake, () => {
    var_knopf = 0
})
var_knopf = 0
basic.showString("XMAS")
basic.showLeds(`
    . . . . .
    . # . # .
    # # . # #
    . # . # .
    . . . . .
    `)
basic.forever(() => {
    if (var_knopf == 0) {
        basic.showLeds(`
            . . . . .
            . # . # .
            # # . # #
            . # . # .
            . . . . .
            `)
    }
})
basic.forever(() => {
    if (input.temperature() >= 50) {
        basic.showLeds(`
            . . # . .
            . . # . .
            . . # . .
            . . . . .
            . . # . .
            `)
        music.playTone(262, music.beat(BeatFraction.Half))
        music.playTone(330, music.beat(BeatFraction.Half))
    }
})
basic.forever(() => {
    if (var_knopf == 0) {
        basic.setLedColor(basic.rgbw(
        25,
        0,
        0,
        0
        ))
        basic.pause(100)
        basic.setLedColor(basic.rgbw(
        0,
        25,
        0,
        0
        ))
        basic.pause(100)
        basic.setLedColor(basic.rgbw(
        0,
        0,
        25,
        0
        ))
        basic.pause(100)
    }
})
basic.forever(() => {
    if (var_knopf == 1) {
        music.setTempo(47)
        basic.pause(500)
        basic.setLedColor(0)
        for (let var_durchgaenge = 0; var_durchgaenge <= 1; var_durchgaenge++) {
            music.playTone(330, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Half))
            music.playTone(330, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Half))
            music.playTone(330, music.beat(BeatFraction.Quarter))
            music.playTone(392, music.beat(BeatFraction.Quarter))
            music.playTone(262, music.beat(BeatFraction.Quarter))
            music.playTone(262, music.beat(BeatFraction.Eighth))
            music.playTone(294, music.beat(BeatFraction.Eighth))
            music.playTone(330, music.beat(BeatFraction.Whole))
            music.playTone(349, music.beat(BeatFraction.Quarter))
            music.playTone(349, music.beat(BeatFraction.Quarter))
            music.playTone(349, music.beat(BeatFraction.Quarter))
            music.playTone(349, music.beat(BeatFraction.Eighth))
            music.playTone(349, music.beat(BeatFraction.Eighth))
            music.playTone(349, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Eighth))
            music.playTone(330, music.beat(BeatFraction.Eighth))
            if (var_durchgaenge == 0) {
                music.playTone(330, music.beat(BeatFraction.Quarter))
                music.playTone(294, music.beat(BeatFraction.Quarter))
                music.playTone(294, music.beat(BeatFraction.Quarter))
                music.playTone(330, music.beat(BeatFraction.Quarter))
                music.playTone(294, music.beat(BeatFraction.Half))
                music.playTone(392, music.beat(BeatFraction.Half))
            } else {
                music.playTone(392, music.beat(BeatFraction.Quarter))
                music.playTone(392, music.beat(BeatFraction.Quarter))
                music.playTone(349, music.beat(BeatFraction.Quarter))
                music.playTone(294, music.beat(BeatFraction.Quarter))
                music.playTone(262, music.beat(BeatFraction.Whole))
            }
        }
        basic.setLedColor(basic.rgbw(
        0,
        0,
        0,
        0
        ))
        var_knopf = 0
        basic.pause(1500)
    }
})
basic.forever(() => {
    if (var_knopf == 2) {
        music.setTempo(56)
        basic.pause(500)
        basic.setLedColor(0)
        for (let var_durchgaenge = 0; var_durchgaenge <= 1; var_durchgaenge++) {
            music.playTone(262, music.beat(BeatFraction.Half))
            music.playTone(349, music.beat(BeatFraction.Half))
            music.playTone(349, music.beat(BeatFraction.Quarter))
            music.playTone(392, music.beat(BeatFraction.Quarter))
            music.playTone(349, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Quarter))
            music.playTone(294, music.beat(BeatFraction.Half))
            music.playTone(294, music.beat(BeatFraction.Half))
            music.playTone(294, music.beat(BeatFraction.Half))
            music.playTone(392, music.beat(BeatFraction.Half))
            music.playTone(392, music.beat(BeatFraction.Quarter))
            music.playTone(440, music.beat(BeatFraction.Quarter))
            music.playTone(392, music.beat(BeatFraction.Quarter))
            music.playTone(349, music.beat(BeatFraction.Quarter))
            music.playTone(330, music.beat(BeatFraction.Half))
            music.playTone(262, music.beat(BeatFraction.Half))
            music.playTone(262, music.beat(BeatFraction.Half))
            if (var_durchgaenge == 0) {
                music.playTone(440, music.beat(BeatFraction.Half))
                music.playTone(440, music.beat(BeatFraction.Quarter))
                music.playTone(494, music.beat(BeatFraction.Quarter))
                music.playTone(440, music.beat(BeatFraction.Quarter))
                music.playTone(392, music.beat(BeatFraction.Quarter))
                music.playTone(349, music.beat(BeatFraction.Half))
                music.playTone(294, music.beat(BeatFraction.Half))
                music.playTone(262, music.beat(BeatFraction.Quarter))
                music.playTone(294, music.beat(BeatFraction.Half))
                music.playTone(392, music.beat(BeatFraction.Half))
                music.playTone(330, music.beat(BeatFraction.Half))
                music.playTone(349, music.beat(BeatFraction.Whole))
            } else {
                music.playTone(440, music.beat(BeatFraction.Half))
                music.playTone(440, music.beat(BeatFraction.Quarter))
                music.playTone(494, music.beat(BeatFraction.Quarter))
                music.playTone(440, music.beat(BeatFraction.Quarter))
                music.playTone(392, music.beat(BeatFraction.Quarter))
                music.playTone(349, music.beat(BeatFraction.Half))
                music.playTone(294, music.beat(BeatFraction.Half))
                music.playTone(262, music.beat(BeatFraction.Quarter))
                music.playTone(294, music.beat(BeatFraction.Half))
                music.playTone(392, music.beat(BeatFraction.Half))
                music.playTone(330, music.beat(BeatFraction.Half))
                music.playTone(349, music.beat(BeatFraction.Whole))
            }
        }
        basic.setLedColor(basic.rgbw(
        0,
        0,
        0,
        0
        ))
        var_knopf = 0
        basic.pause(1500)
    }
})
basic.forever(() => {
    if (var_knopf > 0) {
        basic.showLeds(`
            . . . . .
            . . . . .
            . . # . .
            . . . . .
            . . . . .
            `)
        basic.pause(50)
        basic.showLeds(`
            . . . . .
            . # . # .
            . . # . .
            . # . # .
            . . . . .
            `)
        basic.pause(50)
        basic.showLeds(`
            # . . . #
            . # . # .
            . . # . .
            . # . # .
            # . . . #
            `)
        basic.pause(50)
        basic.showLeds(`
            # . # . #
            . # . # .
            # . # . #
            . # . # .
            # . # . #
            `)
        basic.pause(50)
        basic.showLeds(`
            # . # . #
            . . . . .
            # . . . #
            . . . . .
            # . # . #
            `)
        basic.pause(50)
    }
})

LG pappl