MATLAB App Designer: Error while evaluating TimerFcn for timer 'timer-5' Undefined function 'write' for input arguments of type 'string'.
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yu Zhu
am 20 Sep. 2022
Beantwortet: Shreyansh Mehra
am 23 Sep. 2022
Hi, i am trying to use a timer to send data through serial port to arduino at a fixed rate. However, the error is like this: Error while evaluating TimerFcn for timer 'timer-5' Undefined function 'write' for input arguments of type 'string'.
This is the code related to the timer:
function startupFcn(app)
app.mytimer = timer('Period',0.2,'ExecutionMode','fixedRate');
app.mytimer.TimerFcn = @app.TimerCallback; % Your Timer Callback
end
This is the timer call back function:
function timertt = TimerCallback(app, ~, ~)
% Timer callback
app.sendData(app.motor_qc);
end
function sendData(app,tosend)
tosend = string(tosend);
write(app.arduino,tosend,"string");
end
I'm sure "write" for "string" can work ouside the timer. I used a button to trigger the sendData function, and it works well. But if it is inside the timer, it doesn't work. Is there any solution for this?
0 Kommentare
Akzeptierte Antwort
Shreyansh Mehra
am 23 Sep. 2022
Hello,
Please refer to the following post, which presents solutions that are possibly relevant to this error message:
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!