Is it possible to read from a rotary encoder continuously in the background while being able to call other MATLAB functions?

2 次查看(过去 30 天)
If I do someting like this, I can get input from my rotary encoder.
a = arduino('COM4','Uno','Libraries','rotaryEncoder');
encoder = rotaryEncoder(a,'D3','D2',1024);
i=1;
tic
while toc < 5
count(i) = readCount(encoder);
i = i+1;
end
If possible, I would like to be able to read the position of the rotary encoder continuously, but have that going on in the background so I can still call other functions.
So
%Start reading from rotary encoder
%Call other functions while still reading from the rotary encoder
%Stop reading from rotary encoder
Is there a way to do this in MATLAB?
Thanks

回答(1 个)

Image Analyst
Image Analyst 2018-12-12
You can have a timer setup to run it. I do that in some of my programs where I have it poll a switch that the user can hit to snap a picture, yet they are still able to interact with other controls on the GUI.

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by