const int enA = 6;
const int in1 = 7;
const int in2 = 8;
-byte speedA = 255;
+byte speedA = 120; // DX
// motor two
const int enB = 5;
const int in3 = 4;
const int in4 = 3;
-byte speedB = 255;
+byte speedB = 100;
// Servo vars
int pos = 0; // variable to store the servo position
const byte servoPIN =9 ;
const byte middle = 90; // Centratura servo
const int spausa = 10; // Pausa movimenti servo
-const byte sx = 10; // Min SX
-const byte dx = 170; // Maz DX
+const byte sx = 30; // Min SX
+const byte dx = 150; // Maz DX
Servo myservo; // Non c'e' bisogno di extern se e' dichiarato in questo scope
// Ultrasuoni
const byte ledPIN = 13;
long duration;
int distance;
-const int minDistance = 10;
+const int minDistance = 20;
////////////////////////
// Funzioni:
// so it takes ~29.1 milliseconds for a cm.
distance = (duration / 58.2); // Atmegas are not found of divisions
// Distance is half of (out + back)
+ distance = constrain(distance,4,35);
#ifdef DEBUG
Serial.print("Distanza oggetto: ");
Serial.println(distance);
// so it takes ~29.1 milliseconds for a cm.
distance = (duration / 58.2); // Atmegas are not found of divisions
// Distance is half of (out + back)
+ distance = constrain(distance,4,35);
return distance;
}
// so it takes ~29.1 milliseconds for a cm.
distance = (duration / 58.2); // Atmegas are not found of divisions
// Distance is half of (out + back)
+ distance = constrain(distance,4,35);
#ifdef DEBUG
Serial.print("Distanza oggetto: ");
Serial.println(distance);
//distance = (duration / 2) / 29.1; // Speed is ~300m/s,
// so it takes ~29.1 milliseconds for a cm.
distance = (duration / 58.2); // Atmegas are not found of divisions
+ distance = constrain(distance,4,35);
// Distance is half of (out + back)
return distance;