LIGHT SOURCE FOLLOWER

Light follower Stepper

#include <AccelStepper.h>
#define HALFSTEP 8
// Motor pin definitions
#define motorPin1 12 // IN1 on the ULN2003 driver 1
#define motorPin2 11 // IN2 on the ULN2003 driver 1
#define motorPin3 10 // IN3 on the ULN2003 driver 1
#define motorPin4 9 // IN4 on the ULN2003 driver 1
int d;
// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
void setup() {
stepper1.setMaxSpeed(200);
stepper1.setAcceleration(10000);
stepper1.runToNewPosition(0);
delay(3000);

}//–(end setup )—

void loop() {
int sensorValue0 = analogRead(A0);
int sensorValue1 = analogRead(A1);
d=sensorValue0-sensorValue1;

if (d > 15) {
stepper1.moveTo(stepper1.currentPosition()+1);
stepper1.run();
}
if (d < -15) {
stepper1.moveTo(stepper1.currentPosition()-1);
stepper1.run();
}
if ((d <= 15)&&(d >= -15)) {
stepper1.stop();
}
if ((sensorValue0 <= 50 )&&(sensorValue0 <= 50 )) {
stepper1.runToNewPosition(0);

}
}