Daniel Havlik
Published © CC BY-SA

Eieruhr

Eine einfache Eieruhr mit dem Calliope Mini mit einstellbarer Zeit.

EasyFull instructions provided1 hour1,198
Eieruhr

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1

Story

Read more

Schematics

Editor-Screenshot

Screenshot vom Block-Editor http://pxt.calliope.cc/
Bildschirmfoto 2017 02 27 um 22 58 00 cvrx2utmcl

Code

Javascript-Code

Typescript
Javascript-Code für http://pxt.calliope.cc/
let start = 0
let restzeit = 0
let vergangene_sek = 0
let zeit = 0
let einstellmodus = false
basic.forever(() => {
    if (!(einstellmodus)) {
        vergangene_sek = (input.runningTime() - start) / 1000
        restzeit = zeit - vergangene_sek
        if (restzeit <= 0) {
            while (!(einstellmodus)) {
                basic.showLeds(`
                    # . . . #
                    . # # # .
                    . . # . .
                    . # . # .
                    . . # . .
                    `)
                for (let i = 0; i < 4; i++) {
                    music.playTone(Note.G5, music.beat(BeatFraction.Sixteenth))
                    music.rest(music.beat(BeatFraction.Sixteenth))
                }
                basic.showLeds(`
                    . # . # .
                    . # # # .
                    . . # . .
                    . # . # .
                    . . # . .
                    `)
                for (let i = 0; i < 4; i++) {
                    music.playTone(Note.C5, music.beat(BeatFraction.Sixteenth))
                    music.rest(music.beat(BeatFraction.Sixteenth))
                }
            }
        } else {
            basic.showNumber(restzeit)
        }
    } else {
        zeit = 10
        while (einstellmodus) {
            basic.showNumber(zeit)
        }
    }
})
input.onButtonPressed(Button.A, () => {
    zeit += -10
    if (zeit < 1) {
        zeit = 10
    }
})
input.onButtonPressed(Button.B, () => {
    zeit += 10
})
input.onGesture(Gesture.Shake, () => {
    if (einstellmodus) {
        einstellmodus = false
        start = input.runningTime()
    } else {
        einstellmodus = true
    }
})
einstellmodus = true

Credits

Daniel Havlik

Daniel Havlik

5 projects • 5 followers
Hacker, Maker, Tinkerer at Eigenbaukombinat Halle e.V., Software Engineer, Python Developer, Owner at gocept gmbh & co. kg.

Comments