hi
i’m making a line follow robot, i’m using the qtr-8rc and the orangutan sv 328
the last year i made a similar robot with the qtr-8rc and arduino
http://www.youtube.com/watch?v=E-iqCHxxBI4&list=UUpipeBKOJCC8XDvWUGEQF6g
this year i use the oragutan sv 328
i have a trouble with the sensor and the code
After the calibration i use this line code to give the value of the ubication of the white line
int position = qtr_read_line_white(sensors, QTR_EMITTERS_ON);
when the middle sensors are in the midle of the white line,the value that the code give me is about 2500 instead of the 3500 value.
after this problem i tried the next line code instead with a black line
int position = qtr_read_line(sensors, QTR_EMITTERS_ON);
when the middle sensors are in the midle of the black line, the value that the code give me is about 3500
i think that the problem is something related to the calibration or ther read the white line
here is all my code
#include <pololu/qtr.h>
#include <pololu/orangutan.h>
#include <pololu/digital.h>
#define M1 30
#define M2 30
int main() {
clear();
print("LYNX");
set_motors(0,0);
int lastError = 0;
unsigned char qtr_rc_pins[]={IO_D0, IO_D1, IO_C0, IO_C1, IO_C2, IO_C3, IO_C4, IO_C5};
qtr_rc_init(qtr_rc_pins,8,2000,255);
wait_for_button_press(BUTTON_A);
clear();
print("calibrating");
int i;
for (i = 0; i < 250; i++) // make the calibration take about 5 seconds
{
qtr_calibrate(QTR_EMITTERS_ON);
delay(20);
}
clear();
print("press B");
wait_for_button_press(BUTTON_B);
//set_motors(M1,M2);
while(1)
{ unsigned int sensors[8];
int position = qtr_read_line_white(sensors, QTR_EMITTERS_ON);
//int position = qtr_read_line(sensors, QTR_EMITTERS_ON);
int error = position - 3500;
int motorSpeed = (1/4) * error + (7) * (error - lastError);
lastError = error;
int m1Speed = M1 - motorSpeed;
int m2Speed = M2 + motorSpeed;
if (m1Speed < 0)
m1Speed = 0;
if (m2Speed < 0)
m2Speed = 0;
if (m1Speed >45)
m1Speed = 45;
if (m2Speed > 45)//50
m2Speed = 45;
//set_motors(m1Speed,m2Speed);
clear();
lcd_goto_xy(0,0);
print_long (error);
lcd_goto_xy(0,1);
print_long (position);
}
return 0;
}