Micropython's Image.ALL_CLOCKS[hour] list has 12 LED patterns that resemble an analog clock hand at each hour. It can be used for more than timekeeping though. It can also point in the direction you are tilting the micro:bit! This visual feedback will be useful for tilt-controlling the cyber:bot.
First, let’s train an example script that displays each hour hand at 12, 1, 2 and all the way through 11.
Example script: display_clock_positions
- Enter, name, and save display_clock_positions.
- Click the Send to micro:bit button.
- Verify that it displays all the clock hand positions.
# display_clock_positions from microbit import * sleep(1000) while True: for hour in range(0, 12): print("hour =", hour) display.show(Image.ALL_CLOCKS[hour]) sleep(1000)