Praveen BabuMohan Kumar
Published © CC BY-NC

Autonomous Bot

An Arduino-based rover that is capable of sensing its environment and navigating without human input.

BeginnerWork in progress2.5 hours2,201
Autonomous Bot

Things used in this project

Story

Read more

Code

Code

Arduino
This is the Trial (or) Base code for the Project and it is under Development. After Completing We will Upload The Full Code .
int r1=13;
int r2=3;
int r3=4;
int r4=7;
int IR1,IR2,IR3,IR4;
int leftmotor1=5;
int leftmotor2=6;
int rightmotor1=10;
int rightmotor2=11;



void setup() 
{
   Serial.begin(9600);
   pinMode(leftmotor1,OUTPUT);
   pinMode(leftmotor2,OUTPUT);
   pinMode(rightmotor1,OUTPUT);
   pinMode(rightmotor2,OUTPUT);
   
   pinMode(IR1,INPUT);
   pinMode(IR2,INPUT);
   pinMode(IR3,INPUT);
   pinMode(IR4,INPUT);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
}

void loop() 
{   
  IR1=digitalRead(r1);
  IR2=digitalRead(r2);
  IR3=digitalRead(r3);
  IR4=digitalRead(r4);
    if ((IR1!=1)&&(IR2!=1)&&(IR3!=1))
   {
     motforward();
   }
  else if(((IR1,IR2,IR3)==1)&&((IR4)!=1))
   {
      motstop();
      delay(1000);
      motbackward();
      delay(2000);
   }
   else if(((IR3,IR1)==1)&&((IR2,IR4)!=1))
   {
      motstop();
      delay(1000);
      motright();
      delay(1000);
      
   }
   else if(((IR2,IR1)==1)&&((IR3,IR4)!=1))
   {
    motstop();
    delay(1000);
    motleft();
    delay(1000);
      
   }
   else if((IR1==1)&&(IR2==1)&&(IR3==1)&&(IR4==1))
   {
      motstop();
   }
   else if (IR4==1)
   {
    motstop();
   }
}
   void motforward()
   {
      digitalWrite(leftmotor1,HIGH);
      digitalWrite(leftmotor2,LOW);
      digitalWrite(rightmotor1,HIGH);
      digitalWrite(rightmotor2,LOW);
    
   }
  void motbackward()
   {

      digitalWrite(leftmotor1,LOW);
      digitalWrite(leftmotor2,HIGH);
      digitalWrite(rightmotor1,LOW);
      digitalWrite(rightmotor2,HIGH);
   }
   void motleft()
   {
      digitalWrite(leftmotor1,LOW);
      digitalWrite(leftmotor2,HIGH);
      digitalWrite(rightmotor1,LOW);
      digitalWrite(rightmotor2,LOW);
   }
   void motright()
   {
      digitalWrite(leftmotor1,LOW);
      digitalWrite(leftmotor2,LOW);
      digitalWrite(rightmotor1,LOW);
      digitalWrite(rightmotor2,HIGH);
   }
   void motstop()
   {
      digitalWrite(leftmotor1,LOW);
      digitalWrite(leftmotor2,LOW);
      digitalWrite(rightmotor1,LOW);
      digitalWrite(rightmotor2,LOW);
   }

Credits

Praveen Babu

Praveen Babu

6 projects • 42 followers
Electronics and communication Engineer Student at KCT,Coimbatore
Mohan Kumar

Mohan Kumar

6 projects • 51 followers
Tech enthusiast with interest in IoT and Embedded systems

Comments