Society of Robots - Robot Forum
Software => Software => Topic started by: garriwilson on December 24, 2013, 04:10:14 PM
-
So this is part of the main code for the 50$ robot:
while(1)
{
//store sensor data
sensor_left=a2dConvert8bit(5);
sensor_right=a2dConvert8bit(4);
//detects more light on left side of robot
if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
{//go left
servo_left(44);
servo_right(44);
}
//detects more light on right side of robot
else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold)
{//go right
servo_left(25);
servo_right(25);
}
//light is about equal on both sides
else
{//go straight
servo_left(25);
servo_right(44);
}
I don't understand the servo speeds. For going straight, shouldn't they be equal? And for going right or left, they should be not equal? Here for going straight the settings are servo_left(25) and servo_right(44), and for going left or right the speeds are equal. How does this work?
-
For reference, these are the servo_left and servo_right functions:
void servo_left(signed long int speed)
{
PORT_ON(PORTD, 0);
delay_cycles(speed);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);
}
void servo_right(signed long int speed)
{
PORT_ON(PORTD, 1);
delay_cycles(speed);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);
}
-
Never mind, found this: http://societyofrobots.com/robotforum/index.php?topic=2724.0 (http://societyofrobots.com/robotforum/index.php?topic=2724.0)