//Arduino IDEに付属のServoライブラリをインクルード
#include <Servo.h>
//サーボモーターを接続するArduinoのピン番号
#define PIN_MOTOR 10
//Servo型のmotor変数を宣言
Servo motor;
void setup() {
//motor.attach関数を呼び出し、サーボモーターを初期化
//PIN_MOTOR: サーボモーターを接続するピン番号を指定
//MINI_ANGLE, MAX_ANGLE: サーボモーターの最小・最大パルス幅を指定
//motor.attach(PIN_MOTOR, MINI_ANGLE, MAX_ANGLE);
//min,maxを省略すると、544μsec, 2400μsecという値がデフォルトで入る
motor.attach(PIN_MOTOR);
}
void loop() {
motor.write(0);
delay(1000);
motor.write(90);
delay(1000);
motor.write(180);
delay(1000);
int i;
for(i = 544; i<=2400; i++){
motor.writeMicroseconds(i);
delay(10);
}
}