[MATLAB] 讀取感應器的值

又到了一周一回的MATLAB NXT程式篇了。

由於最近實在太忙 先放上程式碼 詳請請待下回分解,有興趣的朋友們可以先自行摸索,參照NXC或LeJOS的寫法以及本程式的註解,很容易就可以看懂喔~

%Initialize the working environment
clear all;
close all;
clc;
COM_CloseNXT all;

%Search for NXT and get the NXT profile

hNXT=COM_OpenNXT();

%Set the connected NXT as default handle

COM_SetDefaultNXT(hNXT);
NXT_PlayTone(660,200);
pause(0.3);

%task main
%Initialize light sensor with active light
%Initialize touch sensor

OpenLight(SENSOR_1, ‘ACTIVE’);
OpenSwitch(SENSOR_2);

while GetSwitch(SENSOR_2)==false
LightValue = GetLight(SENSOR_1)*0.09775
end

About CAVEDU 阿吉 - 雜工 (2520 Articles)
CAVEDU 教育團隊 打雜
Contact: Website

1 Comment on [MATLAB] 讀取感應器的值

  1. 太讚啦
    [版主回覆01/10/2011 20:31:26]是啊, 歡迎您自己裝起來玩玩看唷

Leave a comment

Your email address will not be published.


*