Servo is fixed

Hello guys,
I am making a project that detects if a laser is blocked and then does some operations.My servo is connected to +5v external power supply but it gets fixed in one position as soon as all the pins are attached.Here is the code:

#include <Servo.h>

Servo servo;

double _speed;
double DIST = 4.5;
long time1;
bool blocked1 = false;
bool blocked2 = false;
bool unblock = false;
bool blocked = true;
bool enter = false;

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 7, d5 = 6, d6 = 4, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup()
{
servo.attach(2);
servo.write(5);
pinMode(5,OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setCursor(0,0);
// Print a message to the LCD.
lcd.print("Speed");
lcd.setCursor(0, 1);
lcd.print("");
Serial.begin(9600);
}

void loop()
{

if(analogRead(A5)<500)
blocked1 = true;
else
blocked1 = false;
if(analogRead(A0)<500)
blocked2 = true;
else
blocked2 = false;

if(blocked2&&blocked)
{
if(!enter)//recording the first time the flow enters this if block
{
time1 = millis();
enter = true;
}
analogWrite(5,255);
if(analogRead(A5)<300)
{
lcd.print
(DIST*1000/(millis()-time1));
lcd.print("cm/s");
//delay(3000);
servo.write(90);
blocked = false;
servo.detach();

}
}

if(digitalRead( 8 )==HIGH)
unblock = true;
else
unblock = false;
if(unblock)
{
analogWrite(5,0);
servo.write(0);
unblock = false;
}

Serial.println(analogRead(A5));
}

The servo was working fine untill i just changed made the jumper wires longer by connecting more wires.And i have tested it there is continuity.

Please help guys,its urgent.

The problem must be in the servo wiring in that case. If you inadvertently connected it wrongly , it may have damaged it .

You haven't said what is the servo is supposed to do. And you haven't said what it is doing. But if it stopped working when you changed the wiring then despite what you think you probably have a bad connection somewhere. Servos use relatively high currents so they react badly to long wires with bad connections particularly if they are connected via breadboards.

With no idea what components you are using, e.g. what is connected to A0 or A5, I have trouble following your code. Why are you reading A5 to set up blocked1 and then never using it for anything? A circuit diagram might help.

But you apparently have a display and plenty of Serial.prints in there. Do they all show what you expect when you expect them to?

Steve

Skip your current sketch. Load up the servo sweep tutorial.
Does it work? If so, then we can examine your sketch in greater detail.
If not, you need to examine your wiring in greater detail.