モーターの種類はいろいろとありますが、回転の位置を指定できるサーボモータが一般的です。
ここではあえて価格の手ごろなステッピングモーターを使ってみました。
ドライバ回路はトランジスタで組んでみました。
モータの配線がやっかいで、順番を間違えると振動するだけで回転しません。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Stepper.h> | |
const int stepsPerRevolution = 32*64; | |
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11); | |
void setup() { | |
myStepper.setSpeed(10); | |
} | |
void loop() { | |
myStepper.step(stepsPerRevolution); | |
delay(500); | |
myStepper.step(-stepsPerRevolution); | |
delay(500); | |
} |