[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

One thought on “[MATLAB] 讀取感應器的值

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *