Regarding using a function to control a servo motor via Arduino
1 view (last 30 days)
Show older comments
I am currently to create a function that allows me to control a servo motor (Hitech HS55) via an Arduino Uno board. The function (named 'motor') and code are as shown below.
However, whenever I execute the function, all it does is give me the value of the position of the motor and the value of y, yet the servo motor does not turn nor respond.
On the other hand, when I copy and paste the same text onto the command window and execute it, the servo motor will respond.
Why does the servo motor not respond when the function is executed?
Thank you.
0 Comments
Answers (2)
Walter Roberson
on 27 Dec 2018
create the arduino object outside of the function and pass it in. You do not want to have multiple connections and the initialization of the object is expensive as it has to synchronise communication each time.
0 Comments
madhan ravi
on 27 Dec 2018
Edited: madhan ravi
on 27 Dec 2018
I believe the communication between the servo and the arduino is not set right.
0 Comments
Communities
More Answers in the Power Electronics Control
See Also
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!