Skip to main content

Line follower robot


                     It is an intelligent robot which can follow a black line on white background. It is a simple yet interesting project. The robot has two Sensor which senses the black line and follows the black line. with Just few components, this marvellous line following robot will be ready to follow.
The one I have built is based on arduino. you can build with just any microcontroller. I salvaged the parts from old robot and built this one. Check my Grid solver robot that is based on the line follower. same hardware, but the program is changed. I used a sensor which gives High or low depending whether its on black or white path. it gives HIGH '1' when on white line or place. and gives LOW '0' when on black path.
I uses 2x4V battery, that makes it 8 V. I connected only 4 V to the motor driver for few reasons.namely,
1. The motor is 6v
2. It is a 300 rpm motor and supplying 8 V will increase the rpm
3. Increase In rpm would result in the robot to overshoot from the path and get disoriented.
So you guys try with a 100-150 rpm motor. that will be sufficient.
if you have any queries please comment below. and like the video :-P


Algorithm:
There are two sensors; A and B

start
a=0 b=0: move forward
a=1 b=1: move forward
a=1 b=0: turn right
a=0 b=1: turn left
stop





Arduino code:

/*
A1 A2 : 01 forward; 10 reverse
B1 B2 : 01 forward; 10 reverse
*/
int x=0;
int y=0;
void setup(){
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(8, INPUT);
  delay(5000);
}
void loop(){
  x=analogRead(A0);//LEFT
  y=analogRead(A1);//RIGHT
  if (x>=500 && y<=200){
  digitalWrite(2, HIGH);// 
  digitalWrite(3, HIGH);// 
  digitalWrite(4, LOW);// 
  digitalWrite(5, HIGH);//
  }
  else if (x<=200 && y>=500){
  digitalWrite(2, LOW);// 
  digitalWrite(3, HIGH);//
  digitalWrite(4, HIGH);// 
  digitalWrite(5, HIGH);//
  }
  else if (x>=500 && y>=500){
  digitalWrite(2, LOW);// 
  digitalWrite(3, HIGH);//
  digitalWrite(4, LOW);// 
  digitalWrite(5, HIGH);//
  }
  else {
  digitalWrite(2, HIGH);// 
  digitalWrite(3, HIGH);//
  digitalWrite(4, HIGH);// 
  digitalWrite(5, HIGH);//
  }
}


Comments

Popular posts from this blog

Switch debouncer using SR Latch

We use switch in our day to day life to switch ON/OFF a bulb or a fan or  any electrical devices. But when we use switches in digital circuits, we observe a phenomenon called bouncing. This occurs because, when we turn the switch, the mechanical parts vibrate. i.e It toggles between ON and OFF state for some time until the mechanical contact attain equilibrium. this vibrations are minute and are not at all noticeable in electrical circuit. where as in digital circuits, these vibrations create pulses. which are detected by circuits which results in an error.               In the above circuit, there is a switch connected to VCC. You can toggle it between terminal 'a' and terminal 'b'. which as a voltage drop of 'Va' and 'Vb' respectively. In digital circuits if you can observe, it takes a finite amount of time to toggle between terminal 'a' and 'b'. which might approximately take 15ns. Now let us consider the terminal is at 'a'. we

PIC 18F452 Programming: LED blinking using assembly

Here is the basic program you need to start off with when you learn to use a microcontroller. We are using the microchip family PIC microcontroller. Which stands for Peripheral Interface Controller, PIC 18F452 is a 40 pin 8-bit microcontroller with 32 KBytes flash, 1536 Bytes of RAM and 256 Bytes EEPROM. It also boasts 4 timers, and three external interrupt pins. Coming to our first program, We will be using MPLAB for Building this project. Create a new project and select MPASM Suite for compiling. After writing the program, Dont forget to add the linker file and the source file in the source window. The linker file for the PIC 18F452 can be found in the  C:\Program Files\Microchip\MPASM Suite\LKR. search for 18f452. In this program, the Bit RB0, toggles continuously with some delay. Connect an LED to The RB0 Pin, i.e Pin 33.connect a 330E resistor in series with the LED. PROGRAM #INCLUDE p18f452.INC; CONFIG WDT=OFF; disabling the watchdog timer ORG 0; Specifing the st

PIC Programming: making a port bits toggle using assembly

CIRCUIT: Program: #INCLUDE p18f452.INC ORG 0 CLRF TRISD  L1 SETF PORTD CALL DELAY CLRF PORTD CALL DELAY GOTO L1 DELAY MOVLW 0xff MOVWF 0x10 L2 DECF 0x10,F BNZ L2 RETURN END