Created
January 25, 2022 20:57
-
-
Save frigginglorious/1b3a22763345aa3da2020be395a012c7 to your computer and use it in GitHub Desktop.
Card10 High Five Counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#high five counter for Card10 CCC badge. | |
import bhi160 | |
import display | |
import utime | |
import buttons | |
import leds | |
import vibra | |
import color | |
disp = display.open() | |
sensor = 0 | |
fives = 0 | |
orient = bhi160.BHI160Orientation() | |
gyro = bhi160.BHI160Gyroscope() | |
collarray = [] | |
leds.set_all(collarray) | |
color = [255, 0, 0] | |
while True: | |
if len(collarray) > 0: | |
leds.set_all(collarray) | |
samples = orient.read() | |
gyros = gyro.read() | |
if len(samples) > 0: | |
disp.clear() | |
sample = samples[0] | |
# disp.print("Z: %f" % sample.z, posy=60, fg=color) | |
# disp.print() | |
# if(() && ()): | |
if sample.z <= -50 and sample.z >= -90: | |
disp.print("READY!: %f" % fives) | |
leds.gay(1) | |
if len(gyros) > 0: | |
gy = gyros[0] | |
if gy.y <= -150: | |
fives += 1 | |
disp.clear() | |
disp.print("NICE FIVE!") | |
disp.update() | |
vibra.vibrate(500) | |
utime.sleep(3) | |
# collarray.append(color.GREEN) | |
# leds.set_all(collarray) | |
else: | |
disp.print("High Fives: %f" % fives) | |
leds.gay(0) | |
disp.update() | |
utime.sleep(0.1) | |
leds.set_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment