Representation him evaluates encoders from Arduino-Board with matlab in graphics ( Plot )

1 view (last 30 days)
Dear All, I make just a project with Microprozessor Arduino-Board and Matlab. I have connected an Encoder with Arduino-Board. I must select worth from encoder with matlab. this is a code of Matlab.
clear all; close all; clc
a = arduino('COM12', 'uno');
configurePin(a,'D2','DigitalInput');
configurePin(a,'D3','DigitalInput');
configurePin(a,'D4','Unset');
%writeDigitalPin(a,'D4',1);
encoderVal = 0;
oldA = 1;
oldB = 1;
%result = 0;
while 1
result = 0;
newA = readDigitalPin(a,'D2');
newB = readDigitalPin(a,'D3');
if (newA ~= oldA) || (newB ~= oldB)
if (oldA == 1) && (newA == 0)
oldB = oldB
result = (oldB * 2 - 1);
end
end
oldA = newA;
oldB = newB;
change = result
encoderVal = encoderVal + change
end
I begin code from matlab and if I turn encoder, I agree worth in MATLAB Command Window. now I do not want worth any more in MATLAB Command Window, now in graphics. so that I agree with rotation encoders worth in graphics, so-called plot. I do not know like I can make it. can somebody help me please?
thanks

Answers (0)

Categories

Find more on App Building 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!