Things used in this project

Hardware components:
A000066 iso both
Arduino 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 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

Using CA and CC RGB LED by Current Sourcing and Sinking!
Easy
  • 352
  • 23

Protip

RGB LEDs are of two types, common cathode and common anode which behave differently with same Arduino code; how to resolve this.

Arduino Amiga Floppy Disk Reader
Easy
  • 2,242
  • 5

Work in progress

An Arduino powered floppy disk controller and reader for making disk images from old AmigaDOS floppy disks.

Quadrature Encoder Demo
Easy
  • 15
  • 1

Full instructions

Use a 3D printed encoder wheel, LED, and 2 photocells to demonstrate how a quadrature encoder works.

Micro:bit Moisture sensor
Easy
  • 158
  • 4

Protip

In this quick and easy project, you build a micro:bit moisture sensor

3D-Printed, Internet-Controlled, Self-Balancing FPV Robot
Easy
  • 1,612
  • 22

Full instructions

Open source telepresence robot that keeps its balance on two wheels. Controlled from UI in the web browser.

Arduino Controlled USB Trackpad
Easy
  • 2,598
  • 4

Full instructions

I really want to make a Raspberry Pi laptop but just can't find the right size trackpad so in this project we will be salvaging an old one.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login