Regarding to your PR23 DIY Project, I want to ask some question about your analog distance sensor source code.
- CODE: SELECT_ALL_CODE
void analog_sen(void)
{
int distance; // variable for distance measuring
lcd_clr(); // clear lcd
send_string("Distance"); // display string
while(1)
{
lcd_goto(20); // lcd goto 2nd line
read_adc(CHANNEL1); // read adc channel 1 ( analog distance sensor input)
distance = result; // assign distance as the result oft he reading
dis_num(result); // display the value
if (distance< 200) // check if distance less than 200
{
backward(); // backward with full speed
SPEEDL = 255;
SPEEDR = 255;
buzzer = 0;
}
else if (distance< 250) // check if distance less than 250
{
backward(); // backward with medium speed
SPEEDL = 230;
SPEEDR = 230;
buzzer = 0;
}
else if( distance < 300) // check if distance less than 300
{
stop(); // stop
buzzer = 0;
}
else // else, distance more than 300
{
forward(); //forward with medium speed and on buzzer
SPEEDL = 230;
SPEEDR = 230;
buzzer = 1;
}
}
}
Q1: What is 200,250,300?I know its the distance measured by sensor, but in waht unit do them stand?
Q2: Does the sensor always measuring distance while the robot is moving?