24.10.25 센텀고 수업 정보 폭탄 감지 실습
페이지 정보
작성자 asf (211.♡.168.221) 작성일 24-10-25 10:32 조회 3,247 댓글 -21본문
[code]
from microbit import *
import radio
import music
radio.config(group=120)
radio.on()
graph = Image ("11111:11111:11111:11111:11111")
def map(value, froMin, froMax,toMin, toMax):
fromRange = froMax - froMin
toRange = toMax - toMin
valueScaled = float(value-froMin)/float(fromRange)
return toMin + (valueScaled * toRange)
while True:
message =radio.receive_full()
if message:
signal = message[1]
distancelevel = map (signal,-255,0,0,9)
display.show(graph*distancelevel)
if distancelevel > 5 :
music.play(music.BA_DING)
[/code]
from microbit import *
import radio
import music
radio.config(group=120)
radio.on()
graph = Image ("11111:11111:11111:11111:11111")
def map(value, froMin, froMax,toMin, toMax):
fromRange = froMax - froMin
toRange = toMax - toMin
valueScaled = float(value-froMin)/float(fromRange)
return toMin + (valueScaled * toRange)
while True:
message =radio.receive_full()
if message:
signal = message[1]
distancelevel = map (signal,-255,0,0,9)
display.show(graph*distancelevel)
if distancelevel > 5 :
music.play(music.BA_DING)
[/code]
좋아요0
이 글을 좋아요하셨습니다
익명님의 댓글
익명 아이피 (211.♡.230.157) 작성일d