Thorsten Kimmeskamp
Published © GPL3+

Der Calliope mini als elektronisches Maßband

Dein Calliope mini zeigt dir an, wie groß du bist! Du brauchst nur eine Schnur: Lass den Calliope daran pendeln und er berechnet ihre Länge!

AdvancedFull instructions provided1 hour130
Der Calliope mini als elektronisches Maßband

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1

Story

Read more

Code

pendel

JavaScript
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)

let time = 0
let dauer_schwingung_ms = 0
let dauer_vorh_schwingung_ms = 0
let laenge_pendel_cm = 0
let weiter = true
while(weiter) {
    if (input.acceleration(Dimension.Strength) > 1200) {
        dauer_schwingung_ms = input.runningTime() - time
        if (dauer_schwingung_ms > 700) {
            if (Math.abs(dauer_vorh_schwingung_ms-dauer_schwingung_ms) < 25) {
                weiter = false
            }
            dauer_vorh_schwingung_ms = dauer_schwingung_ms
            time = input.runningTime()
            led.setBrightness(255)
        }
    } else {
        led.setBrightness(0)
    }
}

basic.showIcon(IconNames.Yes)
dauer_schwingung_ms = (dauer_schwingung_ms + dauer_vorh_schwingung_ms) / 2
laenge_pendel_cm = Math.pow(dauer_schwingung_ms / 100 / Math.PI, 2) * 9.81

input.onButtonPressed(Button.A, function () {
    basic.showNumber(dauer_schwingung_ms)
})
input.onButtonPressed(Button.B, function () {
    basic.showNumber(laenge_pendel_cm)
})

Credits

Thorsten Kimmeskamp
19 projects • 13 followers

Comments