Developing/Python
[Python] 마이크로비트로 모스부호 송수신기 만들기
KwonYongHyeon
2021. 8. 28. 19:37
from microbit import *
uart.init(115200)
while True:
if button_a.is_pressed() and button_b.is_pressed():
uart.write("ㅤ")
sleep(300)
elif button_a.is_pressed():
uart.write("·")
sleep(300)
elif button_b.is_pressed():
uart.write("-")
sleep(300)
if uart.any() == True:
readdata = uart.read()
display.scroll(readdata)
Python으로 Microbit를 이용해 모스부호 송수신기를 만들어봤다.
Microbit에서 A버튼을 누르면 점(·), B버튼을 누르면 선(-)이 보내지며, A버튼과 B버튼을 함께 누르면 띄어쓰기가 되어 컴퓨터로 보내진다.
물론 Microbit의 LED를 이용해 컴퓨터에서 보낸 메시지를 받을 수도 있다.
위 사진은 Tera Term에 Microbit를 연결하여 Microbit로 모스부호를 보내본 모습. Microbit에서 보내니 Tera Term에 잘 뜬다.