Photovore V1
A photovore is basically a robot that chases light.
Some good (and simple) examples are here and here.
The basic sensor is as follows:

The LDR is in series with the other resistor making a voltage divider. This can then be used to measure the light.
An alternate version is to reverse the order and a make the top resistors either side of a potentiometer. This allows you to adjust the resistance and fine tune the sensitivity in one direction or another.
My experiment uses an arduino and a servo. The LDRs are mounted on the servo and then are used to track the light source. This is obviously just a testing platform for now.
The code I used has a few twists to it. Simply going in the direction of the light made it very glitchy. In addition, it was pretty slow. So if the difference is close…its good enough. It its far, jump further ahead.
// tracks two LDRs with a servo
#include <Servo.h>
#include <Math.h>
Servo myservo; // create servo object to control a servo
int potpin0 = 4; // analog pin used to connect the potentiometer
int potpin1 = 5; // analog pin used to connect the potentiometer
int val0; // variable to read the value from the analog pin
int val1; // variable to read the value from the analog pin
int servoPosition;
int increment;
void setup() {
myservo.attach(8); // attaches the servo on pin 8 to the servo object
servoPosition=90; //90 degrees
}
void writePosition(){
//limit the values
servoPosition = min(servoPosition,180);
servoPosition = max(servoPosition,0);
myservo.write(servoPosition); // sets the servo position according to the scaled value
delay(150); // waits for the servo to get there
}
void loop()
{
val0 = analogRead(potpin0); // reads the value of the potentiometer (value between 0 and 1023)
val1 = analogRead(potpin1);
increment = 0;
int diff = abs(val0 - val1);
if (diff > 10) {
increment = 2; //small difference=small sweep
}
if (diff > 50) {
increment = 5;
}
if (diff > 80) {
increment = 15; //big difference
}
if (val0 > val1){
servoPosition = servoPosition + increment;
} else {
servoPosition = servoPosition - increment;
}
writePosition();
}
Here is the youtube of the robot in action


