Created
March 13, 2026 10:04
-
-
Save anthonygrees/22ce7f5f21f11d856c188751eb29ab39 to your computer and use it in GitHub Desktop.
Ashley
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
| from microbit import * | |
| import music | |
| # Define the angry face image | |
| angry_face = Image.ANGRY | |
| # Scroll the text once at startup | |
| display.scroll("IAMMrFrantz") | |
| # Main program loop | |
| while True: | |
| # Check if BOTH buttons A and B are pressed together | |
| if button_a.is_pressed() and button_b.is_pressed(): | |
| # Cool animation: spinning arrow | |
| display.clear() | |
| for _ in range(3): | |
| display.show(Image.ARROW_N) | |
| sleep(100) | |
| display.show(Image.ARROW_NE) | |
| sleep(100) | |
| display.show(Image.ARROW_E) | |
| sleep(100) | |
| display.show(Image.ARROW_SE) | |
| sleep(100) | |
| display.show(Image.ARROW_S) | |
| sleep(100) | |
| display.show(Image.ARROW_SW) | |
| sleep(100) | |
| display.show(Image.ARROW_W) | |
| sleep(100) | |
| display.show(Image.ARROW_NW) | |
| sleep(100) | |
| # Play a victory tune | |
| music.play(music.POWER_UP) | |
| display.show(Image.YES) | |
| sleep(1000) | |
| display.clear() | |
| # Wait for buttons to be released | |
| while button_a.is_pressed() or button_b.is_pressed(): | |
| sleep(100) | |
| sleep(500) | |
| # Check if button A is pressed (only) | |
| elif button_a.is_pressed(): | |
| # Show angry face | |
| display.show(angry_face) | |
| # Wait while button is held down | |
| while button_a.is_pressed(): | |
| sleep(100) | |
| # Clear display after releasing button | |
| display.clear() | |
| sleep(500) | |
| # Check if button B is pressed (only) | |
| elif button_b.is_pressed(): | |
| # Clear display and play music | |
| display.clear() | |
| # Play a built-in melody | |
| music.play(music.ENTERTAINER) | |
| # Clear display after music | |
| display.clear() | |
| sleep(500) | |
| # Check for clap/loud sound (micro:bit V2 only) | |
| if microphone.current_event() == SoundEvent.LOUD: | |
| # Cool rainbow-like effect across the display | |
| display.clear() | |
| for brightness in range(0, 10, 2): | |
| display.show(Image.HEART * brightness) | |
| sleep(100) | |
| for brightness in range(9, -1, -2): | |
| display.show(Image.HEART * brightness) | |
| sleep(100) | |
| # Play a cheerful tune | |
| music.play(music.JUMP_UP) | |
| display.clear() | |
| sleep(500) | |
| # Small delay to prevent overwhelming the processor | |
| sleep(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment