auto calibration code
//sag = right
//sol = left
for (int i = 0; i < 250; i++)
{ if ( 0 <= i && i < 5 ) hafifsagadon();
if ( 5 <= i && i < 15 ) hafifsoladon();
if ( 15 <= i && i < 25 ) hafifsagadon();
if ( 25 <= i && i < 35 ) hafifsoladon();
if ( 35 <= i && i < 45 ) hafifsagadon();
if ( 45 <= i && i < 55 ) hafifsoladon();
if ( 55 <= i && i < 60 ) hafifsagadon();
if ( i >= 60 ) {digitalWrite(motorpower,LOW); delay(3);}
qtrrc.calibrate();
delay(4);
}
.
.
.
Void loop(){
}
void motorkontrol(int sagmotorpwm, int solmotorpwm){
digitalWrite(motorpower, HIGH);
if(sagmotorpwm<=0) {
sagmotorpwm=abs(sagmotorpwm);
digitalWrite(sagmotor1, LOW);
digitalWrite(sagmotor2, HIGH);
analogWrite(sagmotorpwmpin, sagmotorpwm);
}
else {
digitalWrite(sagmotor1, HIGH);
digitalWrite(sagmotor2, LOW);
analogWrite(sagmotorpwmpin, sagmotorpwm);
}
if(solmotorpwm<=0) {
solmotorpwm=abs(solmotorpwm); //
digitalWrite(solmotor1, LOW);
digitalWrite(solmotor2, HIGH);
analogWrite(solmotorpwmpin, solmotorpwm);
}
else {
digitalWrite(solmotor1, HIGH);
digitalWrite(solmotor2, LOW);
analogWrite(solmotorpwmpin, solmotorpwm);
}
}
void frenle(){motorkontrol(0,0);}
void hafifsagadon(){motorkontrol(70,-70);}
void sertsagadon(){motorkontrol(0,250);}
void hafifsoladon(){motorkontrol(-70,70);}
void sertsoladon(){motorkontrol(250,0);}
void sagdan180don(){motorkontrol(-200,200);}
void soldan180don(){motorkontrol(200,-200);}
void geri(){motorkontrol(-200,-200);}