Things used in this project

Hardware components:
A000066 iso both
Arduino UNO & Genuino UNO
×1
09670 01
SparkFun Dual H-Bridge motor drivers L298
×1
IR sensor
×2
11026 02
Jumper wires (generic)
×1
Software apps and online services:
Ide web
Arduino IDE
Hand tools and fabrication machines:
Hy gluegun
Hot glue gun (generic)
Screw Driver
line following Robotic kit

Schematics

Circuit Block Diagram
2017 05 10 13 43 03 jd7qakz9tr

Code

Arduino Based Line follower Robot C/C++
/*-------definning Inputs------*/
#define LS  2    // left sensor
#define RS  5    // right sensor


/*-------definning Outputs------*/
#define LM1 11    // left motor
#define LM2 10    // left motor
#define RM1 9    // right motor
#define RM2 6     // 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)==LOW) && (digitalRead(RS)==LOW))    // Condition_1 stop
{    
    MoveForward();
  }
  
  if((digitalRead(LS)==HIGH) && (digitalRead(RS)==HIGH))  //CONDITION-2 FORWRD
  {
      Stop();
    }
  if((digitalRead(LS)==LOW) && (digitalRead(RS)==HIGH))  // RIGHT
  {
    TurnLeft();
  }
  if((digitalRead(LS)==HIGH) && (digitalRead(RS)==LOW))
  {
    TurnRight();
  }
}



void MoveForward()
{
    analogWrite(LM1, 50);
    analogWrite(LM2, 0);
    analogWrite(RM1, 50);
    analogWrite(RM2, 0);
    delay(20);
}

void TurnRight()
{
    analogWrite(LM1, 0);
    analogWrite(LM2, 60);
    analogWrite(RM1, 60);
    analogWrite(RM2, 0);
    delay(30); 
}

void TurnLeft()
{
    analogWrite(LM1, 60);
    analogWrite(LM2, 0);
    analogWrite(RM1, 0);  
    analogWrite(RM2, 60);
    delay(30);
}

void Stop()
{
    analogWrite(LM1, 0);
    analogWrite(LM2, 0);
    analogWrite(RM1, 0);
    analogWrite(RM2, 0);
    delay(20);
}

Credits

Img 3443
Zubayer Al Billal Khan

Embedded Engineer

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Create a PCB from Scratch with Upverter
Easy
  • 155
  • 4

Full instructions

This tutorial is intended as an example to carry out the Hackster live Meetup of May 2017, that is the creation of a PCB with Upverter.

I Keep my Cucumber Growing Conditions Moist - Part 2
Easy
  • 212
  • 4

Full instructions

This is the next step with an Ultrasonic HC-SR04 Echo and LCD 1602.

Laser Stuff
Easy
  • 530
  • 3

A laser module that makes light patterns.

LEDog Collar
Easy
  • 946
  • 10

Full instructions

The LEDog collar lights up when it gets dark, helping you locate your dog from far away.

Handheld Infinity Kaleidoscope Group Kit
Easy
  • 2,695
  • 30

Full instructions

Use the orientation sensor in your Arduino 101 to control a cool Petri dish infinity-mirror illusion. This project is great for groups.

Arduino 101 BLE RGB Lamp
Easy
  • 544
  • 7

Full instructions

Create your own RGB controlled lamp with Arduino 101 using BLE.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback