tak2저격글2 ·
2024.10.18 ·
조회 1,785
tak2저격글2
from microbit import *
import audio
led_image = Image("11111:11111:11111:11111:11111")
touch_image = Image("00000:09090:00000:90009:09990")
shake_image = Image("99099:99099:00900:09090:00900")
timer=0
audio.play(Sound.HELLO)
while True:
display.show(led_image * ((microphone.sound_level()/255) * 9) )
if pin_logo.is_touched():
timer = 0
display.show(touch_image)
audio.play(Sound.HAPPY)
elif accelerometer.was_gesture('shake'):
timer = 0
display.show(shake_image)
audio.play(Sound.GIGGLE)
else:
sleep(5000)
timer = timer + 1
if timer == 60 :
display.show(Image.ASLEEP)
audio.play(Sound.YAWN)
elif timer == 120 :
display.show(Image.CONFUSED)
audio.play(Sound.SAD)
elif timer == 180 :
display.show(Image.ANGRY)
audio.play(Sound.MYSTERIOUS)