フィルターのクリア

Hello guys, please help me to solve the below mentioned error regarding clearing arduino object

6 ビュー (過去 30 日間)
Darshan Teraiya
Darshan Teraiya 2017 年 4 月 23 日
編集済み: EngEdgarHS 2017 年 5 月 19 日
please do help me ASAP.

回答 (2 件)

Darshan Teraiya
Darshan Teraiya 2017 年 4 月 23 日
[y,fs]=audioread('Blank Space.mp3');
a = arduino('COM3','UNO');
x = writeDigitalPin(a,'D13',1);
if x==1
sound(y,fs)
else
clear sound;
end
clear a;
clear x;
%%Error using morning_alarm (line 2)
MATLAB connection to Arduino Uno at COM3 exists in your workspace. To create a new connection, clear the existing object.

EngEdgarHS
EngEdgarHS 2017 年 5 月 19 日
編集済み: EngEdgarHS 2017 年 5 月 19 日
Hi, you cannot use x this way. If you are using pin 13 as digital output, try:
x = 1;
writeDigitalPin(a, 'D13', x);
but if you want to read state of this pin as digital input (I think you want to do this by the format of your code), try:
[y,fs]=audioread('Blank Space.mp3');
configurePin(a,'D13', 'digitalInput');
x = readDigitalPin(a,'D13');
if x==1
sound(y,fs)
else
clear sound;
end
For clear Arduino object, try it:
clear board;
if ~isempty(instrfind)
fclose(instrfind);
delete (instrfind);
end
clear a;
Good luck.

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by