Arduino Uno LDR Servo Control is a unique program used by the uno to control two servos based on the Light falling on two separate LDRs. the Arduino code provided has been tested in our lab and it seems to be working according to the need. additionally , interested viewers can also watch our YouTube channel for its operation.
Arduino Uno Code:
//electronikprojects.com
//like share and subscribe
#includeServo myservo;
int pos = 0;
int lightPin = A0;
Servo myservo1;
int pos1 = 0;
int lightPin1 = A2;
void setup() {
myservo.attach(8);
myservo1.attach(9);
}
void loop() {
int lightLevel =analogRead(lightPin);
int lightLevel1 =analogRead(lightPin1);
lightLevel = map(lightLevel, 0, 1023, 0, 179);
lightLevel1 = map(lightLevel1, 0, 1023, 0, 179);
pos = constrain(lightLevel, 0, 179);
pos1 = constrain(lightLevel1, 0, 179);
myservo.write(pos);
delay(100);
myservo1.write(pos1);
delay(100);
}