Monday, 26 March 2018

circuit diagram's and coding of line following robot.

Assalam o alikum!
                           
                          this article will show code and circuit diagram of l.f.r

1)                                this diagram show's how l.f.r work's


Working of Line Follower Robot using Arduino

2)              when lfr is on track (following black line).

moving forward,left,right and stoping.

Working of Arduino Line Follower Robot
Turning left to line follower robot using arduino



Turning right to line follower robot

Stopping Arduino Line Following Robot

circuit diagram






---------x-------x-----x------x------x-------x------x------x------x------x-----x-----x------x-----x----x----------

CODE


/*------ Arduino Line Follower Code----- */
/*-------definning Inputs------*/
#define LS 2      // left sensor
#define RS 3      // right sensor
/*-------definning Outputs------*/
#define LM1 4       // left motor
#define LM2 5       // left motor
#define RM1 6       // right motor
#define RM2 7       // right motor
void setup()
{
  pinMode(LS, INPUT);
  pinMode(RS, INPUT);
  pinMode(LM1, OUTPUT);
  pinMode(LM2, OUTPUT);
  pinMode(RM1, OUTPUT);
  pinMode(RM2, OUTPUT);
}
void loop()
{
  if(digitalRead(LS) && digitalRead(RS))     // Move Forward
  {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
  }

  if(!(digitalRead(LS)) && digitalRead(RS))     // Turn right
  {
    digitalWrite(LM1, LOW);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
  }

  if(digitalRead(LS) && !(digitalRead(RS)))     // turn left
  {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, LOW);
    digitalWrite(RM2, LOW);
  }

  if(!(digitalRead(LS)) && !(digitalRead(RS)))     // stop
  {
    digitalWrite(LM1, LOW);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, LOW);
    digitalWrite(RM2, LOW);
  }
}


No comments:

Post a Comment

Final year project for electronic engineering

assalam o alikum! INTRODUCTION:                                                    before going to hovercraft i'll put some light o...