LoginSignup
13
17

More than 5 years have passed since last update.

Raspberry Pi でサーボモータ制御

Last updated at Posted at 2016-05-22

新しい環境(raspbian-stretch)で動作しなくなっていました。
新しい記事 では標準のライブラリを使って制御しています。こちらを参照してください。


PWM信号とやらが面倒で敬遠してたんですが、サーボモータをお手軽に制御できるライブラリがあるみたいです。ということで試してみました。

準備

GitHubからクローンしてビルド・インストールします。

git clone https://github.com/richardghirst/PiBits.git
cd PiBits/ServoBlaster/user/
make servod
sudo ./servod

今回使用したサーボモータは、SG90 MicroServo という機種です(写真参照)。駆動用の電源は単三電池を4つ繋いだ電池パックを使用しています。VccとGroundを電池に接続し、PWMをGPIOの4番ピンに接続します。Groundはさらに、GPIO側のGround端子とも接続が必要です(このためにブレッドボードを挟んでます)。

PWM = 橙
Vcc = 赤
Ground = 茶

IMG_1741.jpg

これで準備完了です。

使い方

/dev/servoblaster に回転角(0~99%)を送るだけのシンプルな操作です。

echo 0=0% | sudo tee /dev/servoblaster
echo 0=99% | sudo tee /dev/servoblaster

細かい制御については、以下のドキュメントを参照してください。
https://github.com/richardghirst/PiBits/tree/master/ServoBlaster

(その他の)参考URL

http://www.micropik.com/PDF/SG90Servo.pdf
http://cihatkeser.com/servo-control-with-raspberry-pi-in-5-minutes-or-less/

13
17
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
13
17