redefine speed

This commit is contained in:
Thefeli73 2021-04-13 22:29:15 +02:00
parent 3ba28c950a
commit 34feb811e9

View File

@ -107,17 +107,23 @@ void loop() {
temp_loops++; temp_loops++;
} }
if(safe_angle!=0 && safe_angle<50 ){ if(abs(safe_angle)<50 ){
if(safe_angle<0){ speed = 8*safe_angle;
if(speed<0){
digitalWrite(MotorPinB, CW); digitalWrite(MotorPinB, CW);
digitalWrite(MotorPinA, CCW); digitalWrite(MotorPinA, CCW);
speed -= 30;
} }
else{ else if(speed>0){
digitalWrite(MotorPinB, CCW); digitalWrite(MotorPinB, CCW);
digitalWrite(MotorPinA, CW); digitalWrite(MotorPinA, CW);
speed += 30;
} }
speed = 30 + 8*abs(safe_angle); else {
speed = constrain(speed, 0, 250); speed = 0;
}
speed = abs(speed);
speed = constrain(speed, 0, 249);
analogWrite(MotorSpeedB, speed); //Wheel close to connections analogWrite(MotorSpeedB, speed); //Wheel close to connections
analogWrite(MotorSpeedA, speed); //First experiment wheel analogWrite(MotorSpeedA, speed); //First experiment wheel
} }