MATLAB Answers

Cannot program Arduino Uno Board

94 views (last 30 days)
Liew Yean Choon
Liew Yean Choon on 19 Jun 2018
Answered: zhe cheng on 18 Apr 2019
Hi, I'm facing problem to connect my Arduino Uno board using MATLAB. I have search around the internet for around 7 hours and still cannot find the solution. I am really in big problem, I need to for my assignment. Can anyone help me please?
>> a = arduino();
Updating server code on board Uno (COM23). Please wait (might take a few minutes).
Cannot program board Uno (COM23). Please make sure the board is supported and the port and board type are
correct. For more information, see Arduino Hardware Troubleshooting.
I have tried changing the name of C:\User\user_name\Documents\Arduino file to other name but when I run the program again a new Arduino file is created in C:\User\user_name\Documents\.

  1 Comment

Liew Yean Choon
Liew Yean Choon on 19 Jun 2018
this is my a = arduino('COM23','Uno','Trace',true)
"C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\core\WInterrupts.c.o"
c:\programdata\matlab\supportpackages\r2017b\3p.instrset\arduinoide.instrset\arduino-1.8.1\hardware\tools\avr\bin\../lib/gcc/avr/4.9.2/../../../../avr/bin/ar.exe:
unable to rename 'C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\core\core.a'; reason: Permission
denied
Using library MWArduino in folder:
C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\libraries\MWArduino
(legacy)
Using library Wire at version 1.0 in folder:
C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\hardware\arduino\avr\libraries\Wire
Using library Servo at version 1.1.2 in folder:
C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\libraries\Servo
Using library SPI at version 1.0 in folder:
C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\hardware\arduino\avr\libraries\SPI
exit status 1

Sign in to comment.

Answers (4)

Menghan
Menghan on 19 Jun 2018
Can you first confirm that the downloaded Arduino IDE works fine on your computer? To do that, go to the folder which is returned by typing "arduinoio.IDERoot" in MATLAB and then open the IDE manually. Try upload an empty sketch to the same board and see if you get the same error.
If yes, check if you have write permission to this folder C:\Users\ACER\AppData\Local\Temp\

  1 Comment

Liew Yean Choon
Liew Yean Choon on 25 Jun 2018
After uninstalling everything in my computer, I have it works several times. But when I reinstalling the Arduino IDE and write a code into my arduino uno, now the MATLAB fails again.
"C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\hardware\tools\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW/ArduinoServer.ino.elf" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\sketch\ArduinoServer.ino.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\MWArduino\MWArduino.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\MWArduino\MWProtocolBase.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\MWArduino\MWProtocolSerial.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\MWArduino\MWProtocolWiFi.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\Wire\Wire.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\Wire\utility\twi.c.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\SPI\SPI.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\Servo\avr\Servo.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\Servo\sam\Servo.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW\libraries\Servo\samd\Servo.cpp.o" "C:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW/core\core.a" "-LC:\Users\ACER\AppData\Local\Temp\ArduinoServer\MW" -lm
c:/programdata/matlab/supportpackages/r2017b/3p.instrset/arduinoide.instrset/arduino-1.8.1/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: could not run lto-wrapper
collect2.exe: error: ld returned 1 exit status
Using library MWArduino in folder: C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\libraries\MWArduino (legacy)
Using library Wire at version 1.0 in folder: C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\hardware\arduino\avr\libraries\Wire
Using library SPI at version 1.0 in folder: C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\hardware\arduino\avr\libraries\SPI
Using library Servo at version 1.1.2 in folder: C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\libraries\Servo
exit status 1

Sign in to comment.


Luis Delfin Puron
Luis Delfin Puron on 23 Sep 2018
I was facing the same problem and solved it by setting the variable arduinoio.IDERoot to an address which current user has access to read and write. In my case it was: arduinoio.IDERoot = 'C:\\Program Files (x86)\\Arduino' Hope it helps.

  0 Comments

Sign in to comment.


Ogheneovo Idolor
Ogheneovo Idolor on 5 Apr 2019
Try running MATLAB as Admin. Worked for me.

  0 Comments

Sign in to comment.


zhe cheng
zhe cheng on 18 Apr 2019
change the port
it helps.

  0 Comments

Sign in to comment.

Sign in to answer this question.