Daniel Havlik
Published © CC BY-SA

Tachometer (Fahrradcomputer)

Messen und anzeigen der Geschwindigkeit wie bei einem Fahrradcomputer.

EasyFull instructions provided1 hour1,372
Tachometer (Fahrradcomputer)

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1

Software apps and online services

Calliope mini pxt.calliope.cc

Story

Read more

Schematics

http://pxt.calliope.cc/ Screenshot

Bildschirmfoto 2017 02 26 um 20 33 09 rqttemk7rh

Code

Javascript-Code

JavaScript
In http://pxt.calliope.cc/ auf Javascript umschalten, dann den Code per copy&paste einfügen.
let last_time = 0
let time_diff = 0
let speed = 0
let new_time = 0
let umfang = 0
basic.forever(() => {
    basic.showString("" + speed)
    basic.pause(100)
    if (input.runningTime() - last_time > 2000) {
        speed = 0
    }
})
input.onButtonPressed(Button.A, () => {
    new_time = input.runningTime()
    if (last_time > 0) {
        time_diff = new_time - last_time
        speed = 36 * (umfang / time_diff) / 10
    }
    last_time = new_time
})
umfang = 2200

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