Help with GUI matlab to control a servomotor

1 view (last 30 days)
Hi, I would like to know if someone could help me to solve this error: "MATLAB connection to Uno at COM3 exists in your workspace. To create a new connection, clear the existing object."
I am working with a slider to move a servomotor and I don´t know how to solve it, I have tried to "clear all" in the last line of the function and it still no working. This is the code:
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
global position
global pos
position=get(handles.slider1,'Value');
pos=double(position);
assignin('base','pos',position);
a = arduino('COM3','Uno','Libraries','Servo');
assignin('base','arduino',a);
s = servo(a,'D2');
assignin('base','s',s);
writePosition(s,pos);
  1 Comment
FRANCISCO JOSÉ DEL MORAL CONDE
It works once and then it works if I delete the variables "s" and "a" or do a "clear all".

Sign in to comment.

Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!