Toggle Navigation
Hatchery
Eggs
FlyHigh
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import bhi160 import display import utime disp = display.open() sd = bhi160.BHI160Accelerometer() eps = 0.2 def readsample1(): t = utime.time_ms() while True: samples = sd.read() if len(samples) > 0: sample = samples[0] if not (abs(sample.x) < eps and abs(sample.y) < eps and abs(sample.z) < eps): return utime.time_ms() - t def readsample2(): while True: samples = sd.read() if len(samples) > 0: sample = samples[0] if (abs(sample.x) < eps and abs(sample.y) < eps and abs(sample.z) < eps): return disp.clear().print("FlyHigh... by Skyp", posx=0, posy=0).update() utime.sleep(3) while True: disp.clear().print("Throw!", posx=0, posy=0).update() readsample2() disp.clear().print("Flying...", posx=0, posy=0).update() rs = readsample1() t = float(rs)/float(1000) t2 = t*t meter = 9.81*t2/4 disp.clear().print("Height: %f m" % meter).update() utime.sleep(8)