Skip to content

Instantly share code, notes, and snippets.

@frigginglorious
Created January 25, 2022 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frigginglorious/1b3a22763345aa3da2020be395a012c7 to your computer and use it in GitHub Desktop.
Save frigginglorious/1b3a22763345aa3da2020be395a012c7 to your computer and use it in GitHub Desktop.
Card10 High Five Counter
#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