Created
January 14, 2026 20:47
-
-
Save laurivosandi/5ce894886a073bb7ed06c128cdb60872 to your computer and use it in GitHub Desktop.
Go Tell Aunt Rhody Suzuki violin training on HIP badge
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
| notes = """ | |
| c#5@2 c#5 b4 a4@2 a4@2 b4@2 b4@2 c#5 b4 a4@2 e5@2 e5 d5 c#5@2 c#5@2 b4 a4 b4 c#5 a4@4 | |
| c#5@2 c#5 d5 e5@2 e5@2 f#5@2 f#5@2 e5 d5 c#5@2 c#5@2 c#5 d5 e5@2 e5@2 f#5@2 f#5@2 e5@4 | |
| c#5@2 c#5 b4 a4@2 a4@2 b4@2 b4@2 c#5 b4 a4@2 e5@2 e5 d5 c#5@2 c#5@2 b4 a4 b4 c#5 a4@4 | |
| """ | |
| import machine | |
| import neopixel | |
| import time | |
| # --- LED setup --- | |
| NUM_LEDS = 16 | |
| rgb = neopixel.NeoPixel(machine.Pin(8), NUM_LEDS) | |
| # --- Pitch → LED index --- | |
| PITCH_MAP = { | |
| "e5": 14, | |
| "f#5": 15, | |
| "g#5": 0, | |
| "a5": 1, | |
| "a4": 10, | |
| "b4": 9, | |
| "c#5": 8, | |
| "d5": 7, | |
| } | |
| BASE_TIME = 0.25 # seconds (@1) | |
| def clear(): | |
| for i in range(NUM_LEDS): | |
| rgb[i] = (0, 0, 0) | |
| rgb.write() | |
| while True: | |
| for token in notes.split(): | |
| parts = token.split("@") | |
| pitch = parts[0].lower() | |
| n = int(parts[1]) if len(parts) == 2 else 1 | |
| if pitch not in PITCH_MAP: | |
| continue | |
| total = n * BASE_TIME | |
| on_time = total * 0.8 | |
| off_time = total * 0.2 | |
| clear() | |
| led = PITCH_MAP[pitch] | |
| # Color rule | |
| if pitch in ("e5", "a4"): | |
| rgb[led] = (255, 0, 0) | |
| else: | |
| rgb[led] = (0, 255, 0) | |
| rgb.write() | |
| time.sleep(on_time) | |
| clear() | |
| time.sleep(off_time) | |
| clear() | |
| time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment