This commit is contained in:
Γιώργος Αντρέου 2024-06-29 00:51:02 +03:00
parent cd1569aa79
commit 56f25b746b

View file

@ -4,7 +4,7 @@ QTRSensors qtr;
const uint8_t SensorCount = 8; const uint8_t SensorCount = 8;
uint16_t sensorValues[SensorCount]; uint16_t sensorValues[SensorCount];
float Kp = 0.07;//set up the constants value float Kp = 0.09;//set up the constants value
float Ki = 0.0008; float Ki = 0.0008;
float Kd = 0.34; float Kd = 0.34;
int P; int P;
@ -15,10 +15,10 @@ int lastError = 0;
boolean onoff = false; boolean onoff = false;
//Increasing the maxspeed can damage the motors - at a value of 255 the 6V motors will receive 7,4 V //Increasing the maxspeed can damage the motors - at a value of 255 the 6V motors will receive 7,4 V
const uint8_t maxspeeda = 200; const uint8_t maxspeeda = 150;
const uint8_t maxspeedb = 200; const uint8_t maxspeedb = 150;
const uint8_t basespeeda = 170; const uint8_t basespeeda = 100;
const uint8_t basespeedb = 170; const uint8_t basespeedb = 100;
//Set up the drive motor carrier pins //Set up the drive motor carrier pins
int mode = 8; int mode = 8;
@ -86,8 +86,8 @@ void loop() {
} }
void forward_brake(int posa, int posb) { void forward_brake(int posa, int posb) {
//set the appropriate values for aphase and bphase so that the robot goes straight //set the appropriate values for aphase and bphase so that the robot goes straight
digitalWrite(aphase, HIGH); digitalWrite(aphase, LOW);
digitalWrite(bphase, LOW ); digitalWrite(bphase, HIGH);
analogWrite(aenbl, posa); analogWrite(aenbl, posa);
analogWrite(benbl, posb); analogWrite(benbl, posb);
} }