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!
Thorsten Kimmeskamp
Published © GPL3+

Calliope mini als EKG-Monitor

Emergency Room lässt grüßen: Der Calliope zeigt deinen Herzschlag als Echtzeit-EKG an, optional mit dem bekannten Pieps-Sound :-)

AdvancedFull instructions provided30 minutes3,254
Calliope mini als EKG-Monitor

Things used in this project

Story

Read more

Code

EGK-Monitor

JavaScript
let zähler = 0
let bpm = 0
let tonAn = false
let generierePuls = false

bpm = 100

input.onButtonPressed(Button.A, () => {
    tonAn = !(tonAn)
    music.rest(music.beat(BeatFraction.Sixteenth))
})

input.onButtonPressed(Button.B, () => {
    generierePuls = !(generierePuls)
})

input.onPinPressed(TouchPin.P2, () => {
    if (bpm > 40) {
        bpm += -10
    }
})

input.onPinPressed(TouchPin.P3, () => {
    if (bpm < 200) {
        bpm += 10
    }
})

pins.onPulsed(DigitalPin.C16, PulseValue.High, () => {
    generierePuls = false
    zähler = 0
    if (tonAn) {
        music.playTone(523, music.beat(BeatFraction.Eighth))
    }
})

basic.forever(() => {
    for (let x = 0; x <= 4; x++) {
        if (zähler == 0) {
            led.plot(x, 1)
        } else if (zähler == 1) {
            for (let y = 0; y <= 4; y++) {
                led.plot(x, y)
            }
        } else if (zähler == 2) {
            led.plot(x, 3)
        } else {
            led.plot(x, 2)
        }
        zähler += 1
        basic.pause(100)
    }
    basic.clearScreen()
})

basic.forever(() => {
    if (generierePuls) {
        zähler = 0
        if (tonAn) {
            music.playTone(523, music.beat(BeatFraction.Eighth))
        }
        basic.pause(60000 / bpm)
    }
})

basic.forever(() => {
    if (zähler > 20 && tonAn) {
        music.playTone(262, music.beat(BeatFraction.Breve))
    }
})

Credits

Thorsten Kimmeskamp

Thorsten Kimmeskamp

19 projects • 13 followers

Comments