Skip to content

Instantly share code, notes, and snippets.

@likersacademia
Last active April 2, 2019 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save likersacademia/3705a1af33bd3c9cd7b2ee576da48a7b to your computer and use it in GitHub Desktop.
Save likersacademia/3705a1af33bd3c9cd7b2ee576da48a7b to your computer and use it in GitHub Desktop.
// モーターを360°回転させるプログラム
#include <Servo.h> //サーボモーターを動かす関数を用意します
#define moterPin 5 //OUTA:5 OUTB:10
Servo myservo;
void setup() {
myservo.attach(moterPin,700,2300);
Serial.begin(9600);
}
void loop() {
//時計回り(when 1450~700 µsec) 逆時計回り(when 1550~2300 µsec) 1500に近い方が回転がおそくなり、1500でとまります
myservo.write(1400); //5秒間時計回り・・1
delay(5000);
myservo.write(1550); //5秒間逆時計回り・・・2
delay(5000);
//1→2と繰り返します。2の後に追加することもできます。
}
// モーターを360°回転させるプログラム
#include <Servo.h> //サーボモーターを動かす関数を用意します
#define moterPin 5 //OUTA:5 OUTB:10
Servo myservo;
void setup() {
myservo.attach(moterPin,700,2300);
Serial.begin(9600);
}
void loop() {
//時計回り(when 1450~700 µsec) 逆時計回り(when 1550~2300 µsec) 1500に近い方が回転がおそくなり、1500でとまります
myservo.write(1400); //5秒間時計回り・・1
delay(5000);
myservo.write(1550); //5秒間逆時計回り・・・2
delay(5000);
//1→2と繰り返します。2の後に追加することもできます。
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment