How to connect two LDR sensors and two servo motors

Hi,

Please help me to connect two LDR sensors with two servo motor, but separated.
LDR-1 is attached to Servo-1,…and LDR-2…to…Servo-2
I can't write the code correctly…Please help me?
Thanks


my code

#include <Servo.h>

Servo myservo1;
Servo myservo2;
int pos = 0;
int LDR1;
int LDR2;

void setup(){
Serial.begin(9600);
myservo1.attach(9);
myservo2.attach(10);
}

void loop(){
int LDR1;
int LDR2;
LDR1 = analogRead(Ao);
Serial.println(LDR1);
if(LDR1<170)
int LDR2;
LDR2 = analogRead(A1);
Serial.println(LDR2);
if(LDR2<170){

myservo1.write(0);
myservo2.write(0);
delay(10);
}else{
myservo1.write(180);
myservo2.write(180);
}

}

Why have you got two 'int LDR1's and three 'int LDR2's? Also the first analog pin is called A0 not Ao (zero NOT lower case o).

Since you always write to both servos at the same time they can't exactly be controlled by different LDRs can they?

What does your code do and what should it do (in detail please)?

Steve

notice this if statement   if(LDR1<170) and this if statement

if(LDR2<170){
   
    }else{
    }

, see the differences?

Please do not post the same question is several places - it just wastes everyone's time. I have already replied to it here

I have reported the matter to the Moderator.

...R

@Burgas61 - if you do not stop spamming the forum with the same question in multiple sections you are in great danger of being banned. Such abuse of the forum wastes time and splits the answers to the questions into many pieces and is against the spirit of the forum which is only kept going by the goodwill of its members

Your other posts have been deleted