const int photocellPin=A0;
const int dirPin = 2;  // Direction
const int stepPin = 4; // Step
const int STEPS_PER_REV = 800;
const int pinOFswitch = 8;  
int count=0;

void setup() {
  // put your setup code here, to run once:
pinMode(A0, INPUT);
pinMode(pinOFswitch, INPUT); 
Serial.begin(9600);
pinMode(dirPin, OUTPUT);
pinMode(stepPin,OUTPUT); 
}

void rolldown() {
digitalWrite(dirPin,HIGH); 
  for(int x = 0; x < STEPS_PER_REV; x++){
    digitalWrite(stepPin,HIGH); 
    delayMicroseconds(2000); 
    digitalWrite(stepPin,LOW); 
    delayMicroseconds(2000); 
  }

delay(1000); 

}

void rollup(){

 digitalWrite(dirPin,LOW);
  for(int x = 0; x < (STEPS_PER_REV); x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(1000);
  }
  delay(1000); 
}

void loop() {
  // put your main code here, to run repeatedly:
int sensorValue = analogRead(photocellPin);
int lux=sensorValue;
float voltage = sensorValue / 1024. * 5;
float resistance = 2000 * voltage / (1 - voltage / 5);
Serial.println(resistance);
delay(5000);



if (lux<=194)
Serial.print("direct sunlight ");
else
Serial.print("no direct sunlight ");

int ValueOFswitch;  
ValueOFswitch = digitalRead(pinOFswitch);  

if (ValueOFswitch == HIGH)   
  sensorValue=0;

if (sensorValue<=194 && count<1 && sensorValue!=0){
rolldown();
count++;
}

if(sensorValue>=194 && count==1 && sensorValue!=0){
rollup();
count=0;
}
}
A4988