Light sensor connected with a stepper motor

Hi guyss,

I’m working on a project for school. I have to connect a stepper motor to a light sensor. I’ve got some help from a friend of mine and I used the SIK guide from sparkfun to start something up.
The SIK guide turns a LED on and off with the following code with the help of a light sensor:

const int sensorPin = 0;
const int ledPin = 9;
int lightLevel, high = 0, low = 1023;
int ledlight = 1;


void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);      // open the serial port at 9600 bps:  
}

void loop()
{
lightLevel = analogRead(sensorPin);
manualTune(); 
ledlight=abs(lightLevel-600)/400*1000;
Serial.println(ledlight);
analogWrite(ledPin, ledlight);
delay(50);
}
void manualTune()
{

lightLevel = map(lightLevel, 0, 1023, 0, 255);
lightLevel = constrain(lightLevel, 0, 255);

}

So I tried to use this code with the code for my stepper motor:

#include <AccelStepper.h> 
#include <math.h>

#define XSTEP 2
#define XDIR 5
#define ENABLEPIN 8
const int sensorPin = 4;
int lightLevel, high = 0, low = 1023;
int ledlight = 2;

#define STEPS (float)200
#define DEGREES (float)360

AccelStepper stepperX(1, XSTEP, XDIR); 


void setup () 
{
  
 pinMode(ENABLEPIN, OUTPUT); 
 
 Serial.begin(9600); 
 digitalWrite(ENABLEPIN,LOW);  
 delay(100); 
 
 

  //Stepper X
 stepperX.setCurrentPosition(0);
 stepperX.setAcceleration(100);
 stepperX.setSpeed(100);
 
}

 void loop ()
 {
   lightLevel = analogRead(sensorPin);
   manualTune(); 
   ledlight=abs(lightLevel-600)/400*1000;
   Serial.println(ledlight);
   while(ledlight==1000) 
   { 
    stepperX.runToNewPosition(14000);
    }
   analogWrite(ENABLEPIN, ledlight);
   delay(50);
 }
void manualTune()
{

lightLevel = map(lightLevel, 0, 1023, 0, 255);
lightLevel = constrain(lightLevel, 0, 255);

}

But I’m having trouble mixing the two codes together to get the result I want, which is:
when the light sensor detects light, the stepper motor turns on for a step of 1300 (that’s the distance I need).

For my setup I’m using:
-light sensor
-cnc shield for the stepper motor
-stepper motor
-10k resistor (for the light sensor)
-a laser light to shine on the light sensor

If someone can help me out, that’d be great!!

I'm working on a project for school. I have to connect a stepper motor to a light sensor.

That doesn't make sense. The light sensor can't drive a stepper motor. Connecting a stepper motor driver and light sensor to the Arduino would make sense.

   while(ledlight==1000) 
   { 
    stepperX.runToNewPosition(14000);
    }

Since ledLight never changes when the while loop is running, if it starts it will never end.