Matlab recognizes arduino but not other code.

조회 수: 14(최근 30일)
Andrew Miller
Andrew Miller 2014년 10월 17일
댓글: Walter Roberson 2016년 11월 11일
I'm pretty new to using matlab/arduino together so this is probably a simple problem. I installed the arduino add-on from mathworks and have gotten matlab to recognize my arduino uno using:
a = arduino('COM3');
but none of the arduino commands work that I have tried:
a.pinMode(13,'output');
pinMode(a,13,'output');
a.digitalWrite(13,1);
digitalWrite(a,13,1);
a.analogRead(0)
analogRead(a,0)
and all of them bring up the same error message:
' _No appropriate method, property, or field pinMode for class arduino._'
I'm not sure why they don't work.

채택된 답변

Andrew Miller
Andrew Miller 2014년 11월 1일
Thanks a lot for your help. I was still having the same problem after installing it as an administrator so I looked at the MATLAB Arduino help and it appears that they have changed the coding syntax. For example: to specify output pins then instead of a.pinMode(22,'output') then it is a.configureDigitalPin(22,'output') or turning on the power instead of a.digitalWrite(22,1) then it is a.writeDigitalPin(22,1). I'm not sure on what version of MTALB the change took place but this fixed the problem.
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 11월 11일
jahanzeb hasmni comments to Andrew Miller:
very authentic and right on the target.

댓글을 달려면 로그인하십시오.

추가 답변(2개)

Geoff Hayes
Geoff Hayes 2014년 10월 18일
Andrew - a similar problem was discussed matlab and arduino where the same error No appropriate method, property, or field pinMode for class arduino. The solution was to install the Arduino support package after having started MATLAB in administrator mode.
  댓글 수: 4
Geoff Hayes
Geoff Hayes 2014년 10월 22일
Obviously you can ignore the part about the other user accounts since there is just you using that computer.
Rather than running the installation package through your browser (which does seem to open a new instance of MATLAB), just save it to file (when I tried it now, the saved file is arduinoio.mlpkginstall). Then launch your instance of MATLAB as an administrator. Change directory to the folder where the install package has been downloaded (or move that file to your default MATLAB directory), then double-click on the file. It will launch the Support Package Installer without launching another instance of MATLAB.

댓글을 달려면 로그인하십시오.


yati j
yati j 2016년 10월 6일
Hi! i had downloaded the package IO Library but after i wanna add to the matlab, matlab see nothing in my folder..how can i add the io library..thank You
  댓글 수: 7
Walter Roberson
Walter Roberson 2016년 10월 6일
Download the .zip into a directory, and unzip it, and in MATLAB cd into the directory and run install_arduino

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by