Last active
April 2, 2019 13:54
-
-
Save likersacademia/3705a1af33bd3c9cd7b2ee576da48a7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// モーターを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の後に追加することもできます。 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// モーターを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