bbcmicrobit / bbcmicrobit/micropython

how to do a interupt with python

Open
#502 2 comments 0 reactions 0 assignees View on GitHub
question
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.