LED Sensor

Ok so i read the article and im trying to get this work but so far i can only get the sensor led to turn on and off im not sure how to get it to turn off and led when its dark around it.

int led1 = 13;
int cath = 2; // negative
int ando = 3;  // positive 

void setup()
 {
   pinMode(led1, OUTPUT);
   pinMode(cath, OUTPUT);
   pinMode(ando, OUTPUT);
   Serial.begin(9600);
 }
 
void loop()
 {
   //TURN SENSOR LED ON
   digitalWrite(cath, LOW);
   digitalWrite(ando, HIGH);
   delay(10);
 //REVERSE BIAS
   digitalWrite(cath, HIGH);
   digitalWrite(ando, LOW);
   //READ LED CAP
   pinMode(ando, INPUT);
   //WRITE TO LED
   digitalWrite(led1,digitalRead(ando));
   //RESET
   pinMode(ando, OUTPUT);
   Serial.print("Reset"); 
 }