新界西北及離島區小學 校際mbot機械車編程比賽 工作坊 (摘要)
TRANSCRIPT
![Page 1: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/1.jpg)
新界西北及離島區小學校際mBot 機械車編程比賽 工作坊 (摘要 )
![Page 2: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/2.jpg)
Copyright © 2015 Coding101 http://coding101.hk
小學組賽規https://goo.gl/po7mTr
![Page 3: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/3.jpg)
Copyright © 2015 Coding101 http://coding101.hk
賽規摘要比賽分為兩個項目進行第一個項目:按任務規定編寫程式完成一連串動作。完成程式後示意在場裁判人員記錄完成時間。隊伍可以利用剩餘時間裝飾mBot機械車,記錄完成時間後不能再更新程式。項目比賽時間為 25分鐘。其後裁判會判定每隊是否完全或部分完成任務規定。每個完成動作會給予 1分。最短時間完成最高分數隊伍為項目勝出者。大會安排在場觀眾投票予最佳設計的mBot,得票最多隊伍獲得最佳設計獎。
![Page 4: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/4.jpg)
Copyright © 2015 Coding101 http://coding101.hk
賽規摘要第二個項目是循線都快比賽每隊在顯示最終賽道後會有 20分鐘時間編寫和測試程式項目會以多輪進行,每輪比賽會以兩隊單循環對賽,勝出者進入下一輪每場比賽為 1分鐘,如果有隊伍追上另一隊伍,該隊為勝出隊伍;如果有隊伍車離開賽道,另一隊會為勝出隊伍;如果兩隊
1分鐘後依然在賽道內,裁判會判斷誰走的較遠為勝出隊伍。偷步兩次隊伍會被判取消該場資格,另一隊為勝出隊伍。每輪之間會有 5分鐘時間咗程式更新時間。最後決賽會每隊單獨作賽,首先完成 3圈隊伍為勝出隊伍。
![Page 5: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/5.jpg)
Copyright © 2015 Coding101 http://coding101.hk
連接 mBot
點擊「連接」 > 「序列埠」> “COMx”
注意:通常是列表中最後一個 COM埠
![Page 6: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/6.jpg)
Copyright © 2015 Coding101 http://coding101.hk
連接 mBot
如果已經連接,會顯示 「序列埠已連接」和機器人模組下mBot亮起綠燈。
![Page 7: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/7.jpg)
Copyright © 2015 Coding101 http://coding101.hk
LED
First 2 options are telling which port to use and which LED to control with. Leave them as they are
But what is “red”, “green” and “blue?
We call these 3 colors RGB color model as we can reproduce any color by combination of these 3 colors.
![Page 8: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/8.jpg)
Copyright © 2015 Coding101 http://coding101.hk
RGB Color Pickerhttp://www.rapidtables.com/web/color/RGB_Color.htm
Try click at any color on the color palette and see what the RGB values are!
Then try the RGB values in the “set led” command!
![Page 9: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/9.jpg)
Copyright © 2015 Coding101 http://coding101.hk
上載程式1.Click Edit > Arduino Mode2.Start your program with “mBot
Program” (note: you can have only one script with mBot program)
- You should see the generated “C” code in the right pane.
![Page 10: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/10.jpg)
Copyright © 2015 Coding101 http://coding101.hk
上載程式3.Click “Upload to Arduino” in the
right pane.4.Wait until compilation
completed and upload finished (may take a minute)
5.Unplug your mBot, and it is ready to go.
![Page 11: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/11.jpg)
Copyright © 2015 Coding101 http://coding101.hk
還原程式When you are done, you want to restore your program such that it again can be controlled by Scratch.
![Page 12: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/12.jpg)
Copyright © 2015 Coding101 http://coding101.hk
還原程式1.Click “Connect” > “Reset
Default Program”2.Wait until Upload completed.
![Page 13: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/13.jpg)
Copyright © 2015 Coding101 http://coding101.hk
控制馬達Add these commands and click Green Flag.
Try different speed values and see what happens.
Change to turn right and click Green Flag.
![Page 14: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/14.jpg)
Copyright © 2015 Coding101 http://coding101.hk
Light Sensor
Add this code, click Green Flag, and observe what happens to the variable “light”
![Page 15: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/15.jpg)
Copyright © 2015 Coding101 http://coding101.hk
Ultrasonic sensor
Step 1. Add these commands and click Green Flag.
Step 2. Move your hand away or towards the ultrasonic sensor, and observe what happens to the distance variable.
![Page 16: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/16.jpg)
Copyright © 2015 Coding101 http://coding101.hk
Line Follower加入下面的程式,點擊綠旗。
找出旁邊 5個情況下, data的值是什麼?
![Page 17: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/17.jpg)
Copyright © 2015 Coding101 http://coding101.hk
自動行駛車當距離少於 10厘米時候,機械車會退後、轉動和然後在檢查距離再前進。
![Page 18: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/18.jpg)
Copyright © 2015 Coding101 http://coding101.hk
Line Follower Logics
3
2
0
1
3
Line Follower Value Direction
0 ↑
1 ↰2 ↱3 ?
![Page 19: 新界西北及離島區小學 校際Mbot機械車編程比賽 工作坊 (摘要)](https://reader033.vdocuments.net/reader033/viewer/2022061604/58efe0301a28ab9c028b468d/html5/thumbnails/19.jpg)
Copyright © 2015 Coding101 http://coding101.hk
Final
Remember this pattern, this is very common