Hello
I am venturing into the programming of a robot mower. I would like to make sure that in the automatic mode when start from standstill does not male a burst going from zero to maximum speed but increases gradually in speed. To do this I was thinking of using the "for" command. Actually the speed increases, however, gradually but during the acceleration totally ignores the signals coming from the sensors. So if there was an obstacle in front of him during the acceleration phase the robot crashes. I have no idea how to fix it. Many thanks in advance
I have no idea how to fix it.
Don't use blocking code, like a for loop. The loop() function already loops. You can make that function change the speed.
I have no idea how to fix it
Something along the lines of this dummy code perhaps
start of loop()
check for obstacles and react if any found
if conditions allow us to accelerate and accelerating is false
set accelerating to true
set speed variable to lowest value
save the start time from millis()
end if
if accelerating is true and X milliseconds has elapsed since last speed increase
call increaseSpeed function
end if
end of loop()
increaseSpeed function
output speed to motors
save the time from millis()
increase the speed variable
if speed is at or above maximum
set accelerating to false
end if
end function
Obviously it needs turning into proper code but it may give you some ideas.
I'll try to do it. Thanks for your help
The demo Several Things at a Time may be of interest.
...R