Arduino - Matlab
古いコメントを表示
currently i use IO package for Matlab, i can light on LED by using digitalWrite function, but now i wan try to blink the LED but don't know how to do it, can someone help me?
採用された回答
その他の回答 (1 件)
Shamnad
2014 年 10 月 31 日
It's not that hard. Check out the below code if you're using MATLAB Support for Arduino (aka ArduinoIO Package)
% code
% ArduinoIO code for Blinking LED
% Connect to Arduino
MyArduino = arduino('COM1');
% Specify Pin Mode
MyArduino.pinMode(13, 'output');
for i = 1:10
% LED on
MyArduino.digitalWrite(13,1);
% Delay for LED on time
pause(.5);
% LED off
MyArduino.digitalWrite(13,0);
% Delay for LED off time
pause(.5);
end
% Close session
delete(MyArduino);
Or else, if you're using MATLAB Support Package for Arduino Hardware Try the below code. Hope this helps.
% code
% Arduino MATLAB Support Package code for Blinking LED
% Connect to Arduino
MyArduino = arduino('COM1', 'UNO');
for i = 1:10
% LED on
writeDigitalPin(MyArduino,13,1);
% Delay for LED on time
pause(.5);
% LED off
writeDigitalPin(MyArduino,13,0);
% Delay for LED off time
pause(.5);
end
clear MyArduino;
カテゴリ
ヘルプ センター および File Exchange で MATLAB Support Package for Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!