Skip to content

Instantly share code, notes, and snippets.

@sh4869 sh4869/sketch.ino
Last active Aug 29, 2015

Embed
What would you like to do?
Arduinoでゆっくりサーボを動かしたい時に使う
#include <Servo.h>
Servo servo;//サーボのインスタンス
int i = 0;
int val = 0;
void setup(){
//サーボの信号線を3番ピンに接続
//(PWMピン以外のピンにも接続可)
servo.attach(3);
}
void loop(){
//サーボ出力
while(i < 120){
delay(10);
val = 150 - i;
servo.write(val);
i++;
}
i = 0;
while(i < 120){
delay(10);
val = 30 + i;
servo.write(val);
i++;
}
i = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.