Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int Motor1Pin1 = 3;
- const int Motor1Pin2 = 4;
- const int Motor2Pin1 = 5;
- const int Motor2Pin2 = 6;
- void setup() {
- pinMode(Motor1Pin1, OUTPUT);
- pinMode(Motor1Pin2, OUTPUT);
- pinMode(Motor2Pin1, OUTPUT);
- pinMode(Motor2Pin2, OUTPUT);
- }
- void loop() {
- GoForward();
- delay(1000);
- GoBackward();
- delay(1000);
- GoRight();
- delay(1000);
- GoLeft();
- delay(1000);
- Stop();
- delay(1000);
- }
- void GoForward(){
- digitalWrite(Motor1Pin2, LOW);
- digitalWrite(Motor1Pin1, HIGH);
- digitalWrite(Motor2Pin2, LOW);
- digitalWrite(Motor2Pin1, HIGH);
- }
- void GoBackward(){
- digitalWrite(Motor1Pin1, LOW);
- digitalWrite(Motor1Pin2, HIGH);
- digitalWrite(Motor2Pin1, LOW);
- digitalWrite(Motor2Pin2, HIGH);
- }
- void GoLeft(){
- digitalWrite(Motor1Pin1, LOW);
- digitalWrite(Motor1Pin2, HIGH);
- digitalWrite(Motor2Pin2, LOW);
- digitalWrite(Motor2Pin1, HIGH);
- }
- void GoRight(){
- digitalWrite(Motor1Pin2, LOW);
- digitalWrite(Motor1Pin1, HIGH);
- digitalWrite(Motor2Pin1, LOW);
- digitalWrite(Motor2Pin2, HIGH);
- }
- void Stop(){
- digitalWrite(Motor1Pin2, LOW);
- digitalWrite(Motor1Pin1, LOW);
- digitalWrite(Motor2Pin1, LOW);
- digitalWrite(Motor2Pin2, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement