Code Section :

const int RMF = 3; // Right Motor Forward IN1
const int RMB = 4; // Right Motor Backward IN2
const int LMF = 5; // Left  Motor Forward IN3
const int LMB = 6; // Left  Motor Backward IN4


void setup() 
{
  pinMode (RMF, OUTPUT); // Setting all the motor pins as OUTPUT
  pinMode (RMB, OUTPUT);
  pinMode (LMF, OUTPUT);
  pinMode (LMB, OUTPUT);
}

void loop()
{    
  delay(3000);

   // Running Robot Forward
   digitalWrite(RMF, HIGH);
   digitalWrite(RMB, LOW);
   digitalWrite(LMF, HIGH);
   digitalWrite(LMB, LOW);

   delay(3000);

   // Running Robot Backward

   digitalWrite(RMF, LOW);
   digitalWrite(RMB, HIGH);
   digitalWrite(LMF, LOW);
   digitalWrite(LMB, HIGH);

   delay(3000);

   // Taking Right Turn

   digitalWrite(RMF, LOW);
   digitalWrite(RMB, LOW);
   digitalWrite(LMF, HIGH);
   digitalWrite(LMB, LOW);

   delay(3000);

   // Taking Left Turn

   digitalWrite(RMF, HIGH);
   digitalWrite(RMB, LOW);
   digitalWrite(LMF, LOW);
   digitalWrite(LMB, LOW);

   delay(3000);

   // Stop the Robot

   digitalWrite(RMF, LOW);
   digitalWrite(RMB, LOW);
   digitalWrite(LMF, LOW);
   digitalWrite(LMB, LOW);
   
   
}

 

SHARE
Previous articleMake Arduino Piano
Next articleArduino Rotating LED Display

LEAVE A REPLY

Please enter your comment!
Please enter your name here