Help with GUI matlab to control a servomotor
1 view (last 30 days)
Show older comments
FRANCISCO JOSÉ DEL MORAL CONDE
on 23 Apr 2020
Commented: FRANCISCO JOSÉ DEL MORAL CONDE
on 23 Apr 2020
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);
Answers (0)
See Also
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!