#include <Servo.h>
#define LDR_PIN 2
Servo servo1;
int servoPin = 6;
void setup(){
servo1.attach(servoPin);
}
int l = analogRead(A2);
void loop(){
for(int i= 0; i<=l; i++)
{
servo1.write(i);
delay(20);
}
for(int i = 180;i>=l;i--)
{
servo1.write(i);
delay(20);
Serial.print(l);
}
}