筆者在露天拍賣上買了一套樂高積木(Lego Mindstorms Education NXT Base Set 9797)。
賣家還貼心地送我一片光碟,光碟內容有 IntroToRobotics 教學與 RobotC_105 (RobotC for Mindstorms 1.05)軟體,筆者就在自己的筆電上安裝這兩份資料。IntroToRobotics 為 RobotC 入門的教學資料,畫面如下:
從如何建立自己的機器人(Build Robot)到修改程式碼(Modify Code)都有教學,所以筆者就開始組起機器人並學習RobotC了,底下為筆者組好的機器人:
底下為筆者讓機器人前進、後退、右轉、左轉的程式:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task main() | |
{ | |
// Moving Forward | |
motor[motorC] = 100; | |
motor[motorB] = 100; | |
wait1Msec(1000); | |
// Moving Backword | |
motor[motorC] = -100; | |
motor[motorB] = -100; | |
wait1Msec(1000); | |
// Turn Right | |
motor[motorC] = 100; | |
motor[motorB] = -100; | |
wait1Msec(1000); | |
// Turn Left | |
motor[motorC] = -100; | |
motor[motorB] = 100; | |
wait1Msec(1000); | |
// Stop | |
motor[motorC] = 0; | |
motor[motorB] = 0; | |
wait1Msec(3000); | |
} |
題外話:
- 用這個 NXT0715.rfw 版本的韌體才可以和 RobotC for Mindstorms 1.05 一起使用。
- 在更新韌體時,因為更新失敗而聽到NXT發出滴滴聲,還以為壞了,Google 找到 LEGO NXT2.0 韌體更新(https://kuozhenrong.weebly.com/blog/lego-nxt20)這一篇文章才解決掉這個問題,底下為節錄此文章的筆記:
(2)點選連接的NXT主機,並按右鍵,點選內容
(3)點選"驅動程式"→"更新驅動程式"
(4)點選"瀏覽電腦上的驅動程式軟體"
(5)點選"讓我從電腦上的裝置驅動程式清單挑選"
(6)點選下載的rfw檔案
沒有留言:
張貼留言