Regarding using a function to control a servo motor via Arduino
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Walter Roberson
2018년 12월 27일
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
madhan ravi
2018년 12월 27일
편집: madhan ravi
2018년 12월 27일
I believe the communication between the servo and the arduino is not set right.
댓글 수: 0
커뮤니티
더 많은 답변 보기: Power Electronics Community
참고 항목
카테고리
Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!