crwdns275420:0crwdne275420:0
crwdns275422:0crwdne275422:0
crwdns275424:0crwdne275424:0 crwdns355708:0crwdne355708:0
crwdns275428:0crwdne275428:0
crwdns275430:0crwdne275430:0
crwdns275432:0crwdne275432:0
- crwdns275434:0crwdne275434:0
- crwdns294837:0crwdne294837:0
- crwdns275438:0crwdne275438:0
crwdns275440:0crwdne275440:0
- crwdns275442:0crwdne275442:0
- crwdns275444:0crwdne275444:0 crwdns275446:0crwdne275446:0 crwdns275448:0crwdne275448:0 crwdns275450:0crwdne275450:0
- crwdns275452:0crwdne275452:0 crwdns275454:0crwdne275454:0
- crwdns275456:0crwdne275456:0
- crwdns275458:0crwdne275458:0
- crwdns275460:0crwdne275460:0 crwdns275462:0crwdne275462:0 crwdns275464:0crwdne275464:0
- crwdns275466:0crwdne275466:0 crwdns275468:0crwdne275468:0 crwdns275470:0crwdne275470:0
- crwdns275472:0crwdne275472:0
crwdns275474:0crwdne275474:0
- crwdns355710:0crwdne355710:0
- crwdns275478:0crwdne275478:0
- crwdns275480:0crwdne275480:0
crwdns275482:0crwdne275482:0
1from microbit import *
2import audio
3
4timer = 0
5display.show(Image(
6 "00000:"
7 "09090:"
8 "00000:"
9 "09990:"
10 "00000"))
11audio.play(Sound.HELLO)
12
13while True:
14 if pin_logo.is_touched():
15 timer = 0
16 display.show(Image.HAPPY)
17 audio.play(Sound.HAPPY)
18 elif accelerometer.was_gesture('shake'):
19 timer = 0
20 display.show(Image.SURPRISED)
21 audio.play(Sound.GIGGLE)
22 else:
23 sleep(500)
24 timer += 0.5
25 # sleep for half a second only to make it react more quickly to logo touch & shake
26
27 if timer == 20:
28 display.show(Image.SAD)
29 audio.play(Sound.SAD)
30 elif timer == 30:
31 display.show(Image.ASLEEP)
32 audio.play(Sound.YAWN)
33 elif timer == 40:
34 display.show(Image.SKULL)
35 audio.play(Sound.MYSTERIOUS)
36 break
37
crwdns275484:0crwdne275484:0
- crwdns275486:0crwdne275486:0
- crwdns275488:0crwdne275488:0
- crwdns355712:0crwdne355712:0
This content is published under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) licence.