Light seeking robot

Well i started making the robot. Did the circuit right, the code is right everything is good except one thing. When i connected 2 motors to pin 2 and pin 3 they werent working. Then after some time of thinking i tried connecting an LED to see if it lights up. When i connected it it felt like there was a 1k resistor in the pin. Heres the schematic http://www.instructables.com/files/deriv/F8D/WLQ5/GLLI7XZZ/F8DWLQ5GLLI7XZZ.LARGE.jpg . And i wrote my own code but as the motors didnt run i thought my code is bad so i used this one then

/****************************************************************************************************************
 * Program for a simple light Seeking Robot.
 * created by: Anuj
 * (c)copyright
 *
 * Robotic base should include differential drive.
 *
 * Physical setup:
 * Two LDRs connected to ground and Analog pin 1(Right) and Analog pin 2(left)
 * base of NPN Transistors on pins 11(right) and 12(left).
 *
*
******************************************************************************************************************/
// Using Arduino Duemilinove

// Pin definitions - attaches a variable to a pin.
const int RightMotor = 2; // This pin is used to enable or disable the Right motor. Connected to the base of an NPN transistor.
const int LeftMotor = 3; // This pin is used to enable or disable the Left motor. Connected to the base of an NPN transistor.
const int RightSensor = 1; // This pin is used to read the value of the Right Sensor.
const int LeftSensor = 2; // This pin is used to read the value of the Left Sensor.

// Variable definitions

int SensorLeft; // This stores the value of the Left Sensor pin to use later on in the sketch
int SensorRight; // This stores the value of the Right Sensor pin to use later on in the sketch
int SensorDifference; // This value is used to determine the difference between the Left and Right

// the setup() method runs once when the program is run. When the
// Arduino is reset, the setup() will be executed once again.

void setup() {

pinMode(LeftMotor, OUTPUT); // Defines this pin as an output. The Arduino will write values to this pin.
pinMode(RightMotor, OUTPUT); // Defines this pin as an output. The Arduino will write values to this pin.
pinMode(LeftSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
pinMode(RightSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
digitalWrite(A1, HIGH); // Enables an internal pullup resistor
digitalWrite(A2, HIGH); // Enables an internal pullup resistor
Serial.begin(9600); // Enables a serial connection through the Arduino to either USB or UART (pins 0&1). Note that the baud rate is set to 9600
Serial.println(" \nBeginning Light Seeking Behavior"); // Placed at the very end of void Setup() so that it is runs once, right before the void Loop()
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop() {
SensorLeft = 1023 - analogRead(LeftSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1);
SensorRight = 1023 - analogRead(RightSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1);
SensorDifference = abs(SensorLeft - SensorRight); // This calculates the difference between the two sensors and then saves it to an integer.

// This section of the sketch is used to print the values of the
// sensors through Serial to the computer. Useful for determining
// if the sensors are working and if the code is also functioning properly.

Serial.print("Left Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorLeft); // Prints the value of the Left Sensor.
Serial.print("\t"); // Prints a tab (space).
Serial.print("Right Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorRight); // Prints the value of the Right Sensor.
Serial.print("\t"); // Prints a tab (space).


// This section of the sketch is what actually interperets the data and then runs the motors accordingly.

if (SensorLeft > SensorRight && SensorDifference > 75) { // This is interpreted as if the Left sensor reads more light than the Right Sensor, Do this:
digitalWrite(RightMotor, HIGH); // This is used to turn Left. Notice the
digitalWrite(LeftMotor, LOW); // opposite motor runs to turn Left.
Serial.println("Left"); // This prints Left when the robot would actually turn Left.
}

if (SensorLeft < SensorRight && SensorDifference > 75) { // This is interpreted as if the Left sensor reads less light than the Right Sensor, Do this:
digitalWrite(RightMotor, LOW); // This is used to turn Right. Notice the
digitalWrite(LeftMotor, HIGH); // opposite motor runs to turn Right.
Serial.println("Right"); // This prints Right when the robot would actually turn Right.
}

else if (SensorDifference < 75) { // This is interpreted as if the difference between the two sensors is under 125 (Experiment to suit our sensors), Do this:
digitalWrite(RightMotor, HIGH); // This is used to go straight. Notice
digitalWrite(LeftMotor, HIGH); // both motors are enabled to go forward.
Serial.println("Forward"); // This prints Forward when the robot would actually go forward.
}
Serial.print("\n");
}

When you print out the sensor values are they reacting to light as expected?

Yes, and when it says forward the LED almost lights up.

How is the test LED connected?

What voltage are you using for the motors?

Do the motors run if you disconnect the 1K resistor from the Arduino pin and connect it to +5V instead?

I tried to connect the LED just connecting to a pin and ground, and my arduino board was connected to USB

rawriano: I tried to connect the LED just connecting to a pin and ground, and my arduino board was connected to USB

In your sketch did you remember to set the pin as an OUTPUT?

Nope i didnt forget it.

EDIT: Maybe it has to do something with that its connected to pin 2 and pin 3 because i saw these are external pins.

EDIT: Maybe it has to do something with that its connected to pin 2 and pin 3 because i saw these are external pins.

Those are pins that can have external signals attached, to trigger an interrupt. Those pins can be used as output pins with no problems.

Yes, and when it says forward the LED almost lights up.

How does a digital device "almost" do something? It either does or it doesn't. There is no "almost" about it.

By almost i mean its like being powered from 1mA

CMon, anyone?