24.10.25 센텀고 정보 수업 폭탄 찾기 실습
본문
from microbit import *
import radio
import music
radio.config(group=120)
radio.on()
graph = Image("00900:00900:00900:00900:99999")
def map(value, fromMin, fromMax, toMin, toMax):
fromRange = fromMax - fromMin
toRange = toMax - toMin
valueScaled = float(value - fromMin) / float(fromRange)
return toMin + (valueScaled * toRange)
while True:
message = radio.receive_full()
if message:
signal = message[1]
distanceLevel = int(map(signal, -255, 0, 0, 9))
display.show(graph * distanceLevel)
if distanceLevel > 5:
music.play(music.BA_DING)
좋아요0
이 글을 좋아요하셨습니다
tak2님의 댓글
tak2 아이피 (192.♡.0.1) 작성일ㄷㄷㄷㄷㄷㄷ