Clear Filters
Clear Filters

Load Arduino Files (coding) in Matlab Command Window

8 views (last 30 days)
I have my coding in forms of arduino (.ino). I need to call or load the files in matlab command window. How can i load the arduino files?

Answers (1)

Walter Roberson
Walter Roberson on 18 Apr 2023
Edited: Walter Roberson on 18 Apr 2023
You cannot.
.ino files are plain-text files, but they are not written in a programming language that MATLAB can execute.
Arduino ino files are put through a pre-processor to create C++ code files, which are then compiled on the host, creating a binary executable to be written to the arduino and executed there.
The arduino does not have a file system; it does not have any ability to store different ino files (or the executables) and invoke the appropriate one at need -- only the ability to send a current executable to the device for execution.
The closest you can get would be to write a "switchyard", code something along the lines of
read a byte
switch() on the byte to call one of several different functions
the function would, if needed, read more parameters from the input line
and then compile the files all into one executable. The MATLAB program would then serialport() the arduino, and then make calls like
inof = dictionary({'start_vacuum', 'advance_motor', 'stop_vacuum'}, {int8(1), int8(2), int8(3)});
parameters = [typecast(3.5, 'int8'), int8(-2)];
write(ARDUINO, [inof('start_vacuum'), parameters])


Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!