Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- exercise10_1_receive
- -- ワイヤレス通信メッセージを受信して外部モニターに流す(受信側プログラム)
- -- 最初は文字サイズ1で表示し右に流れる。次に文字サイズ2で右に流れる。
- local mon = peripheral.wrap("top") -- 上側のモニターを使います宣言
- rednet.open("right") -- 右のモデムを使います宣言
- -- ############# Functions ##############
- function init()
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- end
- function displayString(x, y, msg)
- mon.setCursorPos(x,y)
- mon.write(msg)
- end
- -- ############### Main ################
- while true do
- local id, msg = rednet.receive() -- メッセージを受信するまで待ち続ける
- print(id, msg) --送信元IDとメッセージをターミナル画面に表示
- mon.setTextScale(1)
- local xSize, ySize = mon.getSize()
- for x=1, xSize do
- init()
- displayString(x,1,msg)
- os.sleep(0.3)
- end
- mon.setTextScale(2)
- xSize, ySize = mon.getSize()
- for x=1, xSize do
- init()
- displayString(x,1,msg)
- os.sleep(0.3)
- end
- end
Add Comment
Please, Sign In to add comment