MakeCode Microbit 遙控機器人 (Microbit Remote-Controlled Robot)

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。

If you like this post, please click the ads on the blog or buy me a coffee. Thank you very much.

本篇文章將講解如何製作一個簡易的遙控機器人,此篇文章所使用的機器人為【麥昆智能小車 (Maqueen)】。This post will build a simple remote car with Maqueen which is a micro:bit based robot platform for education.

一、功能如下(Game Design): 

訊號說明(The communication way):

使用英文字母f、b、l、r、s 五個字母,對應動作為:f 為前進、b 為後退、l 為左轉、r 為右轉、s 為停止。Using the first letter of each action: forward, backward, left, right, stop. That is, the letter f stands for forward. The letter b stands for backward, and so on. 

遙控器(The controller)

  • 按下 A + B 按鈕時,送出停止(stop)訊號。Sending a stop signal when button A and B are pressed.
  • Microbit 板子向上傾斜時,送出前進f(forward)訊號。Sending a forward signal when tilting the microbit front.
  • Microbit 板子向下傾斜時,送出後退b(backward)訊號。Sending a backward signal when tilting the microbit back.
  • Microbit 板子向左傾斜時,送出左轉l(left)訊號。Sending a left signal when tilting the microbit to the left.
  • Microbit 板子向右傾斜時,送出右轉r(right)訊號。Sending a right signal when tilting the microbit to the right.

車子(The car)
  • 收到停止(stop)訊號時,車子停止。On receiving a stop signal, the car will stop.
  • 收到前進f(forward)訊號時,車子前進。On receiving a forward signal, the car will move forward.
  • 收到後退f(backward)訊號時,車子後退。On receiving a backward signal, the car will move backward.
  • 收到左轉l(left)訊號時,車子左轉。On receiving a left signal, the car will turn left .
  • 收到右轉r(right)訊號時,車子右轉。On receiving a right signal, the car will turn right .

二、積木程式(Blocks Code)

程式啟動時(On Start):


遙控器(The controller)

  • 按下 A + B 按鈕時,送出停止(stop)訊號。Sending a stop signal when button A and B are pressed.
  • Microbit 板子向上傾斜時,送出前進f(forward)訊號。Sending a forward signal when tilting the microbit front.
  • Microbit 板子向下傾斜時,送出後退b(backward)訊號。Sending a backward signal when tilting the microbit back.
  • Microbit 板子向左傾斜時,送出左轉l(left)訊號。Sending a left signal when tilting the microbit to the left.
  • Microbit 板子向右傾斜時,送出右轉r(right)訊號。Sending a right signal when tilting the microbit to the right.

車子(The car)
  • 收到停止(stop)訊號時,車子停止。On receiving a stop signal, the car will stop.
  • 收到前進f(forward)訊號時,車子前進。On receiving a forward signal, the car will move forward.
  • 收到後退f(backward)訊號時,車子後退。On receiving a backward signal, the car will move backward.
  • 收到左轉l(left)訊號時,車子左轉。On receiving a left signal, the car will turn left .
  • 收到右轉r(right)訊號時,車子右轉。On receiving a right signal, the car will turn right .


三、結果(The Results)
影片(Demo Video):

範例網址(Example Code):https://makecode.microbit.org/_5Ah3eYLyRH49

沒有留言:

張貼留言