http://www.societyofrobots.com/programming_differentialdrive.shtml
and a Sharp IR range finder to control the rear motor so that if it comes to close to the light source it will stop automatically.
This will work.
Another method I have used is this:
if (light_sensors detect a really bright light) // robot is close to light source
then stop_motor();
How would you do this : if (light_sensors detect a really bright light) // robot is close to light source
then stop_motor();
so far my coding for my photoresistors looks like this:
int main(void)
{
int sensor_left=0;
int sensor_right=0;
int threshold=4;
while(1)
{
sensor_left=a2dConert8bit(5);
sensor_right=a2dConvert8bit(4);
if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
{
PORTD |=1<<PD2;
PORTD &= !(1<<PD1);
PORTD |=1<<PD4;
}
else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold))
{
PORTD &=!(1<<PD0);
PORTD |=1<<PD3;
PORTD |=1<<PD4;
}
}
One other question I have is, If i set a port to low, is it considered to be grounded? If not, is there a way to set a port to ground?
Thanks