- Have the arduino emit something when the action is finished, and fread() / fgets() / fgetl() the arduino serial port . Reading from a serial port waits until data is ready (or until timeout). If you take this approach you can also configure callbacks to be triggered when data is available from the serial port. This approach would work especially well if you had configured code on the arduino rather than using the convenience layer such as readDigitalPin()
- After sending the command to the Arduino, request a reading from the Arduino, such as reading a digital pin, knowing that the arduino will not be able to process that until it has finished the previous request. This would work better if you are using the convenience layer rather than sending code to the Arduino yourself.
How to have Matlab wait for Arduino to finish execution?
8 views (last 30 days)
Show older comments
Is it possible to have Matlab wait for code execution on an Arduino before it proceeds without using pause? I am sending data over to an Arduino and then have Arduino do something. Is there any way for me to have Matlab wait for the execution on the Arduino then to continue? I would prefer not to use wait because I have different scenarios where the execution time on the Arduino varies.
0 Comments
Answers (1)
Walter Roberson
on 22 Jun 2020
MATLAB has no idea how long it takes Arduino to finish actions. The only way it could know the Arduino is finished is if the Arduino tells it.
There are two basic choices:
6 Comments
Walter Roberson
on 1 Jul 2020
Unfortunately I have been struggling to install Arduino on my system, so I cannot test this :(
See Also
Categories
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!