Created
August 15, 2016 04:55
-
-
Save takkanm/55e7ba4f1228f1e4bee2e2359207f768 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#define SIGNAL_5PIN 2 | |
#define SIGNAL_6PIN 1 | |
#define POWER_PIN 3 | |
#define MOTOR_POWER 255 | |
#define MOVE_TIME 20000 | |
#define STOP_TIME 1000 | |
void setup() { | |
pinMode(SIGNAL_5PIN, OUTPUT); | |
pinMode(SIGNAL_6PIN, OUTPUT); | |
} | |
void loop() { | |
stop_mortor(); | |
delay(STOP_TIME); | |
foward_mortor(MOTOR_POWER); | |
delay(MOVE_TIME); | |
stop_mortor(); | |
delay(STOP_TIME); | |
back_mortor(MOTOR_POWER); | |
delay(MOVE_TIME); | |
} | |
void stop_mortor() { | |
digitalWrite(SIGNAL_6PIN, LOW); | |
digitalWrite(SIGNAL_5PIN, LOW); | |
} | |
void foward_mortor(int power) { | |
digitalWrite(SIGNAL_6PIN, HIGH); | |
digitalWrite(SIGNAL_5PIN, LOW); | |
analogWrite(POWER_PIN, power); | |
} | |
void back_mortor(int power) { | |
digitalWrite(SIGNAL_6PIN, LOW); | |
digitalWrite(SIGNAL_5PIN, HIGH); | |
analogWrite(POWER_PIN, power); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment