// BTS7960 (veya L298N) motor sürücü bağlantıları. #define solRPWM 6 // Sol motor. #define solLPWM 10 // Sol motor. #define sagRPWM 5 // Sağ motor. #define sagLPWM 9 // Sağ motor. void motor(int solMotorPWM, int sagMotorPWM) { if ( solMotorPWM >= 0 ) { // İleri. analogWrite(solRPWM, solMotorPWM); analogWrite(solLPWM, 0); } else { // Negatifse geri döndür. analogWrite(solRPWM, 0); analogWrite(solLPWM, abs(solMotorPWM)); } if ( sagMotorPWM >= 0 ) { // İleri. analogWrite(sagRPWM, sagMotorPWM); analogWrite(sagLPWM, 0); } else { // Negatifse geri döndür. analogWrite(sagRPWM, 0); analogWrite(sagLPWM, abs(sagMotorPWM)); } } void ileri() { motor(hiz, hiz); } void geri() { motor(-hiz, -hiz); } void sol() { motor(-hiz, hiz); } void sag() { motor(hiz, -hiz); } void dur() { motor(0, 0); } void ileriSol() { motor(hiz / 2, hiz); } void ileriSag() { motor(hiz, hiz / 2); }