Stepper Constructor

この関数は、Arduinoボードに接続された特定のステッピングモータを示すStepperクラスの新しいインスタンスを生成する。setup()やloop()よりも前の、スケッチの最初の方に記述する。パラメータの数は、ステッピングモータとArduinoを、2ピンで接続したのか、4ピンで接続したのかに依存する。

書式

Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2);

Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2, int motor_pin_3, int motor_pin_4);

Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,int motor_pin_3, int motor_pin_4, int motor_pin_5);

引数

stepsモータが一周するのに必要なステップ数。モータの仕様がステップごとの角度で表記されているときは、360をその角度で割って、ステップ数を求める必要がある。例:1ステップ3.6度のときは、360/3.6=100ステップとなる。
pin1, pin2モータに接続するピン番号。
pin3, pin44ピンで接続したときの、残りのピン番号。
pin55ピンで接続したときの、残りのピン番号。

戻り値

Stepperクラスの新しいインスタンス。

訳者註

3個目の書式は、公式ページには記載がありませんが、ソースコード上実装されています。5相のステッピングモータにも対応しています。

使用例

1
Stepper myStepper = Stepper(100, 5, 6); 

オリジナルのページ

https://www.arduino.cc/reference/en/libraries/stepper/stepper/

最終更新日

January 7, 2024

inserted by FC2 system