I want to do in my program a unique delay , that means :
In my programm I put two functions: stop(); and forward(); and I want to do in my loop the function stop(); a delay(1000); and to finish the function forward(); and I want to stay in function forward();
Bb= it’s a button and D1= the distance calculated by the ultrasonic sensor
Before this If the motor turn on and I want to stop them , wait 1 second and turn on them.
But with this program the motor stop, wait 1s, turn on , stop , wait 1s, turn on etc…
Without seeing your full code and a decent description
void forward()
{
...
...
for(;;);
}
The triple dots represent you existing code that you did not post. The for(;;) will hang your code forever at the end of the forward() function so it stays in that function as you described and only a reset of the Arduino will get it out of there.
If this is what you really want is another question; it matches your description in the opening post.
Further note the way I posted the code using code tags; please read the stickies, one of them will tell you how to use code tags.
I can’t do a for endfor or a while endwhile because I’ve the Distance_A , the ultrasonic sensor calculated the distance everytime so If I do a for endfor , it will stop the calcul of the distance.
Maxcubex34:
I can't do a for endfor or a while endwhile because I've the Distance_A
I reckon you need to put aside any thinking about program code for a moment and just describe in English the project you are trying to create and how you want things to happen.
If we understand the context it will make it much easier to help.