240 likes | 673 Views
機器人課程實作教學. LEGO 機器人使用 ROBOTC. ROBOTC 簡介. ROBOTC 機器人程式開發環境是由卡內基美隆大學 (Carnegie Mellon) 所開發,並且開發出許多機器人教育所可以使用的套件。例如: VEX Cortex 、 TETRIX 等可作為機器人教育所使用的套件。 ROBOTC 教學網站& 卡內基美隆大學機器人學院。 ROBOTC 適用包含 LEGO 及 Arduino 等多種系統。. ROBOTC 環境介紹. ROBOTC 操作環境. ROBOTC & LEGO. LEGO 韌體更新流程 -1.
E N D
機器人課程實作教學 LEGO機器人使用ROBOTC
ROBOTC 簡介 • ROBOTC機器人程式開發環境是由卡內基美隆大學(Carnegie Mellon)所開發,並且開發出許多機器人教育所可以使用的套件。例如:VEX Cortex、TETRIX等可作為機器人教育所使用的套件。 • ROBOTC教學網站&卡內基美隆大學機器人學院。 • ROBOTC適用包含LEGO及Arduino等多種系統。
ROBOTC 環境介紹 • ROBOTC操作環境
ROBOTC & LEGO • LEGO韌體更新流程-1
ROBOTC & LEGO • LEGO韌體更新流程-2
ROBOTC & LEGO • LEGO韌體更新流程-3
ROBOTC & LEGO • LEGO韌體更新流程-4
ROBOTC & LEGO • 藍芽傳輸介面 設定-1
ROBOTC & LEGO • 藍芽傳輸介面 設定-2
ROBOTC & LEGO • 藍芽傳輸介面 設定-3
ROBOTC & LEGO • 藍芽傳輸介面 設定-4
ROBOTC & LEGO • 藍芽傳輸介面 設定-5
ROBOTC & LEGO • 藍芽傳輸介面 測試
感測器與連接埠設定 • #pragma config(Sensor, S1, Touch, sensorTouch) • #pragma config(Sensor, S2, Sound, sensorSoundDB) • #pragma config(Sensor, S3, Light, sensorLightActive) • #pragma config(Sensor, S4, Sonar, sensorSONAR) • const tSensors lightSensor = (tSensors) S3;
ROBOTC程式編寫 • 感測器實作-Touch Sensor • const tSensors touchSensor = (tSensors) S1; • task main() • { • while(SensorValue(touchSensor) == 0) • { • motor[motorC] = 100; • motor[motorB] = 100; • } • motor[motorC] = -30; • motor[motorB] = -75; • wait1Msec(1500); • }
ROBOTC程式編寫 • 感測器實作-Sound Sensor • #pragma config(Sensor, S2, soundSensor, sensorSoundDB) • task main() • { • wait1Msec(1000); • while(SensorValue(soundSensor) < 70) • { • motor[motorC] = 75; • motor[motorB] = 75; • } • motor[motorC] = 0; • motor[motorB] = 0; • }
ROBOTC程式編寫 • 感測器實作- Sound Sensor -2 • #pragma config(Sensor, S2, soundSensor, sensorSoundDB) • task main() • { • wait1Msec(1000); • while(true) • { • motor[motorB] = SensorValue[soundSensor]; • motor[motorC] = SensorValue[soundSensor]; • } • }
ROBOTC程式編寫 • 感測器實作-Light Sensor • #pragma config(Sensor, S3, lightSensor, sensorLightActive) • task main() • { • wait1Msec(50); • while(true) • { • if(SensorValue[lightSensor] < 45) • { • motor[motorB] = 60; • motor[motorC] = 20; • } • else • { • motor[motorB] = 20; • motor[motorC] = 60; • } • } • }
ROBOTC程式編寫 • 感測器實作-Sonar Sensor • #pragma config(Sensor, S4, sonarSensor, sensorSONAR) • task main() • { • int distance_in_cm = 20; • while(SensorValue[sonarSensor] > distance_in_cm) • motor[motorB] = 75; • motor[motorC] = 75; • } • motor[motorB] = 0; • motor[motorC] = 0; • }
ROBOTC程式編寫 • 動力輸出控制-1 • #pragma config(Sensor, S1, touch, sensorTouch) • #pragma config(Sensor, S3, lightSensor, sensorLightActive) • task main() • { • while(SensorValue(touch) == 0) • { • wait1Msec(50); • if(SensorValue[lightSensor] < 45) • { • motor[motorB] = 60; • motor[motorC] = 20; • } • else • { • motor[motorB] = 20; • motor[motorC] = 60; • } • } • }
ROBOTC程式編寫 • 動力輸出控制-2 • #pragma config(Sensor, S1, touch, sensorTouch) • #pragma config(Sensor, S3, lightSensor, sensorLightActive) • #pragma config(Sensor, S4, Sonar, sensorSONAR) • task main() • { • while(SensorValue(Sonar)>20) • { • wait1Msec(50); • if(SensorValue[lightSensor] < 45) • { • motor[motorB] = 60; • motor[motorC] = 20; • } • else • { • motor[motorB] = 20; • motor[motorC] = 60; • } • } • }