Last active
August 11, 2024 04:27
-
-
Save LindseyB/6bc5e17a5f1cea3161f8ea407d6a604a to your computer and use it in GitHub Desktop.
CircuitPython code for doing lots of little things on the Adafruit CLUE
This file contains 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
"""Display as many of the sensors and sounds this lil thing can do""" | |
from adafruit_clue import clue | |
clue_display = clue.simple_text_display() | |
tone = 1000 | |
tone_delta = 50 | |
clue.sea_level_pressure = 1015 | |
while True: | |
x, y, z = clue.acceleration | |
clue_display[1].text = "Altitude: {:.1f} m".format(clue.altitude) | |
clue_display[2].text = "Temperature: {:.1f}".format(clue.temperature) | |
clue_display[3].text = "Humidity: {:.1f}".format(clue.humidity) | |
clue_display[4].text = "Accel: ({:.1f}, {:.1f}, {:.1f})".format(x, y, z) | |
clue_display[5].text = "Pressure: {:.3f}hPa".format(clue.pressure) | |
clue_display[6].text = "Proximity: {}".format(clue.proximity) | |
clue_display[7].text = "Gyro: {:.2f} {:.2f} {:.2f}".format(*clue.gyro) | |
clue_display[8].text = "Magnetic: {:.3f} {:.3f} {:.3f}".format(*clue.magnetic) | |
clue_display[9].text = "Color: R: {} G: {} B: {} C: {}".format(*clue.color) | |
clue_display[10].text = "Pad 0: touched" if clue.touch_0 else "Pad 0: not touched" | |
clue_display[11].text = "Pad 1: touched" if clue.touch_1 else "Pad 1: not touched" | |
clue_display[12].text = "Pad 2: touched" if clue.touch_2 else "Pad 2: not touched" | |
clue_display[14].text = "Hack the planet!" | |
# turn pixel cyan if noise bypasses the threshold | |
if clue.loud_sound(sound_threshold=300): | |
clue.pixel.fill((0, 50, 50)) | |
else: | |
clue.pixel.fill(0) | |
# turn white leds on if shake bypasses the threshold | |
if clue.shake(shake_threshold=15): | |
clue.white_leds = True | |
else: | |
clue.white_leds = False | |
if clue.button_b: | |
tone = tone + tone_delta | |
clue.play_tone(tone, 1) | |
if clue.button_a: | |
tone = tone - tone_delta | |
clue.play_tone(tone, 1) | |
clue_display.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment