Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Daniel Havlik
Published © CC BY-SA

Eieruhr

Eine einfache Eieruhr mit dem Calliope Mini mit einstellbarer Zeit.

BeginnerFull instructions provided1 hour5,286
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/

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