Info

This question is closed. Reopen it to edit or answer.

I am workind on a serial communication RS-232.The code is listed below.How can I send the value of the centroid? I want to comunicate with 2 servomotors.Am i sending the value right?I have errors.Please help!

1 view (last 30 days)
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid
rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
plot(bc(1),bc(2), '-m+')
a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2)))));
set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'yellow');
end
bc=[X Y];
z1=atan2(X,0)*180/3.14;
z2=atan2(0,Y)*180/3.14;
s=serial('COM6','BaudRate',1200,'DataBits',8,'parity','none','StopBits',1,'FlowControl','none');
fopen(s);
fprintf(s,'%s\n',Z1);
fprintf(s,'%s\n',z2);
fclose(s);

Answers (0)

Community Treasure Hunt

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

Start Hunting!