Load Arduino Files (coding) in Matlab Command Window

6 Ansichten (letzte 30 Tage)
Noor Amira Ilyanie
Noor Amira Ilyanie am 18 Apr. 2023
Bearbeitet: Walter Roberson am 18 Apr. 2023
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?

Antworten (1)

Walter Roberson
Walter Roberson am 18 Apr. 2023
Bearbeitet: Walter Roberson am 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])

Kategorien

Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by