writePosition does not work inside of a function
Mostrar comentarios más antiguos
So i'm trying to make a function that i can input a number from 0 to 1 and the function turns the servo how i specify. Problem is, the servo just never turns. I don't get an error, it acknowledges the arduino and servo connections, but it just refuses to turn the servo. When i do this in a script, it works just fine. I need help, please.
function servocontrol(theta)
a=arduino();
s=servo(a,'D9');
writePosition(s,theta)
end
3 comentarios
Walter Roberson
el 1 de Mzo. de 2018
I do not recommend creating a connection to arduino each time. I recommend creating it once and storing the connection (a) somewhere that can be accessed. http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
Yousef Gaffary
el 1 de Mzo. de 2018
Walter Roberson
el 1 de Mzo. de 2018
I am not aware of any reason why writePosition would not work in a function. I am, however, concerned about the possibility that there might already be a connection open to the arduino and so the arduino() call inside the function might not be able to communicate properly.
Respuestas (0)
Categorías
Más información sobre MATLAB Support Package for Arduino Hardware en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!