rotary encoder with arduino and matlab

2 次查看(过去 30 天)
hi
I am using a Rotar Encoder when I want to read the count of the encoder pulses in one direction it works good but when I turn the encoder shaft to the other direction the counting won't be decreasing and it would be increasing!!!!
this is the code that I write:
a=arduino('com9','uno','Libraries','RotaryEncoder');
encoder=rotaryEncoder(a,'D2','D3');
for i=1:1000
count=readCount(encoder);
fprintf('count: %d\n',count);
pause(1)
end
and this is the data sheet of the encoder:

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by