Redifinition

Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"

sketch_apr15a:20: error: redefinition of 'int R1'

int R1 = analogRead(LDR1); // reading value from LDR 1

^

C:\Users\JAY\Desktop\sketch_apr15a\sketch_apr15a.ino:16:5: note: 'int R1' previously declared here

int R1 = analogRead(LDR1); // reading value from LDR 1

^

sketch_apr15a:21: error: redefinition of 'int R2'

int R2= analogRead(LDR2); // reading value from LDR 2

^

C:\Users\JAY\Desktop\sketch_apr15a\sketch_apr15a.ino:17:7: note: 'int R2' previously declared here

int R2 = analogRead(LDR2); // reading value from LDR 2

^

sketch_apr15a:22: error: redefinition of 'int diff1'

int diff1= abs(R1 - R2); // Calculating the difference between the LDR's

^

C:\Users\JAY\Desktop\sketch_apr15a\sketch_apr15a.ino:18:7: note: 'int diff1' previously declared here

int diff1= abs(R1 - R2); // Calculating the difference between the LDR's

^

sketch_apr15a:23: error: redefinition of 'int diff2'

int diff2= abs(R2 - R1);

^

C:\Users\JAY\Desktop\sketch_apr15a\sketch_apr15a.ino:19:7: note: 'int diff2' previously declared here

int diff2= abs(R2 - R1);

^

sketch_apr15a:25: error: expected unqualified-id before 'if'

if(diff1 <= error)||(diff2 <= error) {

^

sketch_apr15a:27: error: expected unqualified-id before 'else'

} else {

^

exit status 1
redefinition of 'int R1'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

It looks like you have defined things twice with the same name, possibly because you don't realise that putting int in front of the variable name defines a new variable with that name every time.

If you posted the code you were compiling we'd know definitely what was wrong.

Steve

(deleted)