Книга: Best Arduino Automation Project: Arduino Project Ideas for Automated System
Назад: Schematics
Дальше: 4. Power Saving with Arduino

Motor DriverArduino

const int in1 = 9;

const int in2 = 8;

const int in3 = 4;

const int in4 = 3;

 

void setup() {

  pinMode (in1, OUTPUT);

  pinMode (in2, OUTPUT);

  pinMode (in3, OUTPUT);

  pinMode (in4, OUTPUT);

 

}

 

void loop() {

      //Move Farword

      digitalWrite(in1, HIGH);

      digitalWrite(in2, LOW);

      digitalWrite(in3, HIGH);

      digitalWrite(in4, LOW);

      delay(2000);

 

      //Move Reverse

      digitalWrite(in1, LOW);

      digitalWrite(in2, HIGH);

      digitalWrite(in3, LOW);

      digitalWrite(in4, HIGH);

      delay(2000);

 

      //Move Left

      digitalWrite(in1, HIGH);

      digitalWrite(in2, LOW);

      digitalWrite(in3, LOW);

      digitalWrite(in4, HIGH);

      delay(2000);

 

     //Move Right

      digitalWrite(in1, LOW);

      digitalWrite(in2, HIGH);

      digitalWrite(in3, HIGH);

      digitalWrite(in4, LOW);

      delay(2000);

 

 

}

Назад: Schematics
Дальше: 4. Power Saving with Arduino