24.10.25 정보 수업 마이크로비트 라디오 실습
본문
from microbit import *
import radio
import speech
radio.on()
radio.config(group=15, power=7)
while True:
if button_a.was_pressed():
radio.send("your mommy") # Corrected the typo "your momy"
message = radio.receive() # Moved this line outside the button check
if message:
display.scroll(message)
speech.say(message)
tak2님의 댓글
tak2 아이피 (211.♡.168.221) 작성일
from microbit import *
import radio
import speech
import time
radio.on()
group_number = 2 # Start with group 2
radio.config(group=group_number, power=7)
last_press_time = 0 # To track the last press time
while True:
if button_a.was_pressed():
radio.send("U MOM") # Send the message
if button_b.was_pressed():
current_time = running_time() # Get the current time in milliseconds
if current_time - last_press_time <= 500: # Check if pressed within 0.5 seconds
group_number = 1 # Reset to group 1
display.show("c")
sleep(500)
else:
group_number += 1 # Increment the group number
last_press_time = current_time # Update the last press time
radio.config(group=group_number) # Update the radio group configuration
display.show(group_number)
sleep(500)
message = radio.receive() # Check for incoming messages
if message:
display.scroll(message)
speech.say(message)
sleep(1500)
1111님의 댓글
1111 아이피 (211.♡.168.221) 작성일
from microbit import *
import radio
import audio
import random
radio.config(group=3)
radio.on()
timer = -1
myTurn = False
while True:
if button_a.was_pressed() and button_b.was_pressed():
display.show("3")
sleep(500)
display.show("2")
sleep(500)
display.show("1")
sleep(500)
display.clear()
myTurn = True
timer = random.randint(5,30)
if accelerometer.was_gesture('shake'):
radio.send(str(timer))
display.clear()
audio.play(Sound.GIGGLE)
if myTurn:
if timer > 0:
sleep(1000)
timer = timer - 1
display.show(Image.SKULL)
print(timer)
else :
audio.play(Sound.SOARING, wait=False)
display.scroll("Loser")
message = radio.receive()
if message :
timer = int(message)
1111님의 댓글
1111 아이피 (211.♡.168.221) 작성일
from microbit import *
import radio
import audio
import random
radio.config(group=17)
radio.on()
timer = -1
myTurn = False
while True:
if button_a.was_pressed() and button_b.was_pressed():
display.show("3")
sleep(500)
display.show("2")
sleep(500)
display.show("1")
sleep(500)
display.clear()
myTurn = True
timer = random.randint(5,30)
if accelerometer.was_gesture('shake'):
radio.send(str(timer))
myTurn = False
display.clear()
audio.play(Sound.GIGGLE)
if myTurn:
if timer > 0:
sleep(1000)
timer = timer - 1
display.show(Image.SKULL)
print(timer)
else :
audio.play(Sound.SOARING, wait=False)
display.scroll("Loser")
message = radio.receive()
if message :
timer = int(message)
myTurn=True
ㅁㅇㄴㄻㄴㅇㄻㄴㅇㄹ님의 댓글
ㅁㅇㄴㄻㄴㅇㄻㄴㅇㄹ 아이피 (211.♡.168.221) 작성일빠른 정보 감자함ㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎ