step motor with photocell help

hey guys,i am new at this i need some help with my code…i am trying to get my blinds to open when there is sun and close when its dark… so far i can only get it to go clockwise when there is light and clockwise when there is no light… how do i write to have blinds open when light is detected and stay like that till it gets darker ???
Any help would be appreciated

here is my code so far

//setep motror with photocell
#include <Stepper.h> // Include the ‘Stepper’ Library
int analogPin = A0; ///photocell sensor
Stepper small_stepper(300, 8,10,9,11);

void setup() {

void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);

if (analogValue > 50) {
small_stepper.setSpeed(100); // Set the speed, you can play around with this.
small_stepper.step(1000); // Number of steps to go clockwise
else {
small_stepper.setSpeed(100); // Set the speed to half the above one
small_stepper.step(-1000); // Go the same number of steps, but this time anti-clockwise


Are you confident in the readings from the cell?

If there's any doubt, I'd be inclined to use serial printing to the monitor to confirm to you what the reading is, ala this tutorial. Then I would also use a print inside each "leg" of the if, to shout "I'm in the if leg" or "I'm in the else leg" so you can verify that your logic is taking you to correct parts.

A couple of limit switches would be handy so that you can tell when the blind is fully open or fully closed.