0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Arduinoを使ってサーボモーターを動かす

Posted at

Arduinoを使っていつ買ったのかわからないGeekServoを動かしてみる。

使うもの

  • Arduino UNO R4 Minima
  • GeekServo 9G 360° Motor-Orange
  • VS Code(WindowsPCにインストール、PlatformIOを利用)
  • ブレッドボード
  • ジャンパ線

接続

ArduinoのPWMが出力できるピン(今回は9ピン)とモーターのオレンジ色の線、5Vとモーターの赤色の線、GNDと茶色の線を接続した。

プログラム

Servo.hライブラリを利用する。

#include <Arduino.h>
#include <Servo.h>

Servo myservo;

void setup()
{
  myservo.attach(9, 500, 2500);
}

void loop()
{
  myservo.write(0);
  delay(2000);
  myservo.write(90);
  delay(2000);
  myservo.write(180);
  delay(2000);
  myservo.write(90);
  delay(2000);
}

実行してみたらなんか思っているよりもめっちゃ回っている。
もう少し細かく回したいのですが。。。

サーボモーターの違い

このGeekServo 9G 360° Motor-Orangeは、連続回転サーボと言われていて速度と回転方向のみが制御できるということで、角度指定ができないとのこと。

これとは別にポジショナルサーボと言うものがあり、これは指定した角度まで動いて止まることができるとのこと。
そのため、角度を指定したいならGeekServo 9G Servo-Grayを買うべきだった。。。

結論

ちゃんと下調べしてから買う!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?