Arduinoでサーボモータを動かす
1981 ワード
Arduinoからシンプルにサーボモータを動かしてみたいと思います。
格安のモーターシールドを使います。
Amazonで購入した700円くらいのモーターシールドです。
https://www.amazon.co.jp/gp/product/B01H6N3VIQ/
ソースコードはArduino標準のスケッチ(p05_ServoMoodIndicator)を参考にしました。
ファイル>スケッチ例>10.StarterKit>p05_ServoMoodIndicator
// include the Servo library
#include <Servo.h>
Servo myServo; // create a servo object
int angle; // variable to hold the angle for the servo motor
void setup() {
myServo.attach(10); // 制御するサーボの指定
angle = 90; // 角度指定
myServo.write(angle);
}
Adafruitのサイトでサーボ1は9番ピンと書いてありましたが、私が買ったボードでは10番ピンでした。
https://learn.adafruit.com/adafruit-motor-shield/faq#faq-1315669
Author And Source
この問題について(Arduinoでサーボモータを動かす), 我々は、より多くの情報をここで見つけました https://qiita.com/atsuto/items/720231bb1c230fb32c30著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .