bbcmicrobit / bbcmicrobit/micropython
how to do a interupt with python
- Dominant language
- C
- Stars
- 646
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
```
from microbit import *
img = Image()
mode = 'sos' # light mode and flash mode
while True:
if button_a.is_pressed():
mode = 'flash'
if mode == 'flash':
img.fill(0)
display.show(img)
sleep(40)
img.fill(9)
display.show(img)
sleep(40)
if mode == 'light':
img.fill(9)
display.show(img)
if mode == 'sos':
# s
img.fill(9)
display.show(img)
sleep(500)
display.clear()
sleep(500)
display.show(img)
sleep(500)
display.clear()
sleep(500)
display.show(img)
sleep(500)
display.clear()
sleep(500)
# 0
display.show(img)
sleep(1500)
display.clear()
sleep(1500)
display.show(img)
sleep(1500)
display.clear()
sleep(1500)
display.show(img)
sleep(1500)
display.clear()
sleep(1500)
# s
img.fill(9)
display.show(img)
sleep(500)
display.clear()
sleep(500)
display.show(img)
sleep(500)
display.clear()
sleep(500)
display.show(img)
sleep(500)
display.clear()
sleep(500)
```
hi, i want to change mode when press buttons, but the sleep prevent detect press event,
i want to change mode when press button
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.