The device uses 2 ldrs. It is programmed to check if any of them is low(I mean not receiving light). If so, then it checks if now the other one is low. Based on which ldr was low first, it makes an output. The Arduino sketch is here:
#define led1 3
#define led2 5 #define ldr1 7
#define ldr2 8
int stateLed1=0;
int stateLed2=0;
const int wait=20;
int vala=0;
int valb=0;
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;
int g=0;
int h=0;
int i=0;
int j=0;
int k=0;
int m=0;
int o=0;
int p=0;
int q=0;
int r=0;
int s=0;
int t=0;
int u=0;
int v=0;
int w=0;
int x=0;
int y=0;
int z=0;
void setup()
{
Serial.begin(9600);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(ldr1,INPUT); pinMode(ldr2,INPUT);
}
void loop()
{
vala=digitalRead(ldr1);
valb=digitalRead(ldr2);
if(vala==0)
{
delay(wait);
a=digitalRead(ldr2); delay(wait);
b=digitalRead(ldr2);
delay(wait);
c=digitalRead(ldr2);
delay(wait);
d=digitalRead(ldr2);
delay(wait);
e=digitalRead(ldr2); delay(wait);
f=digitalRead(ldr2);
delay(wait);
g=digitalRead(ldr2);
delay(wait);
h=digitalRead(ldr2);
delay(wait);
i=digitalRead(ldr2); delay(wait);
j=digitalRead(ldr2);
delay(wait);
k=digitalRead(ldr2);
delay(wait);
m=digitalRead(ldr2); if((a+b+c+d+e+f+g+h+i+j+k+m)<12)
{
stateLed1=0;
stateLed2=1;
}
}
if(valb==0)
{
delay(wait);
o=digitalRead(ldr1);
delay(wait); p=digitalRead(ldr1);
delay(wait);
q=digitalRead(ldr1);
delay(wait);
r=digitalRead(ldr1);
delay(wait);
s=digitalRead(ldr1);
delay(wait); t=digitalRead(ldr1);
delay(wait);
u=digitalRead(ldr1);
delay(wait);
v=digitalRead(ldr1);
delay(wait);
w=digitalRead(ldr1);
delay(wait); x=digitalRead(ldr1);
delay(wait);
y=digitalRead(ldr1);
delay(wait);
z=digitalRead(ldr1);
if((o+p+q+r+s+t+u+v+w+x+y+z)<12)
{
stateLed1=1; stateLed2=0;
}
}
digitalWrite(led1,stateLed1);
digitalWrite(led2,stateLed2);
Serial.println(o+p+q+r+s+t+u+v+w+x+y+z);
Serial.println(a+b+c+d+e+f+g+h+i+j+k+m);
Serial.println();
Serial.println();
}
https://www.youtube.com/watch?v=urU2JtPBjk8