Arduino
Switchを加えて、Switchを押すたびに
⓵0度 (1秒) ⇒⓶90度 (1秒) ⇒⓷180度 (1秒) になるように下のプログラムを直してください。
#include <Servo. h>
// サーボのピン番号
const int SERVO_PIN = 9:
// サーボのインスタンス
Servo servo:
// INITがtrueの時は、モーターの位置を0にするだけ
const bool INIT = true;
void setup () {
// put your setup code here, to run once:
servo. attach (SERVO_PIN);
servo. wr ite (0) ;
}
void loop () {
// put your ma in code here, to run repeatedly:
if (INIT) return:|
servo. write (0) ;
delay (3000);
servo. wr ite (45) ;
delay (2000) ;
servo. write (90);
delay (1000) ;
servo. wr ite (180) ;
delay (3000) ;
servo. wr iteMicroseconds (1000);
delay (2000);
servo. writeMicroseconds (2000);
delay (2000);
servo. wr iteMicroseconds (1500) ;
delay (4000);
}
あなたの回答
tips
プレビュー