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

Tachometer (Fahrradcomputer)

Messen und anzeigen der Geschwindigkeit wie bei einem Fahrradcomputer.

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

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