writePosition does not work inside of a function
古いコメントを表示
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 件のコメント
Walter Roberson
2018 年 3 月 1 日
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
2018 年 3 月 1 日
Walter Roberson
2018 年 3 月 1 日
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.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB Support Package for Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!