delay

Hi,

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();

What is the question?

How can I do a "unique" delay between my 2 functions in the loop

I do not know what you mean by "unique delay" and I see no code, so it is hard to give you any advice.

if(Bb==HIGH){
stop();
delay(1000);
avancer();
if(D1<15){
stop();
}
}

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…

Maxcubex34:
Before this If the motor turn on and I want to stop them

Before what?

Do you mean before the Bb button changes from LOW to HIGH?

...R

Yeah

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.

Maxcubex34:
Yeah

We don't charge by the word. Perhaps you could take the trouble to explain more clearly what exactly you want to happen.

...R

{
D1=DistanceA();
boolean Ba = digitalRead(B1);
boolean Bb = digitalRead(B2);
Serial.print(D1);
Serial.print(“cm”);
Serial.println();
delay(100);
if(Ba==HIGH){
tourner();
if(Bb==HIGH){
stop();
delay(1000);
avancer();
if(D1<15){
stop();
}
}
}
}

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.

Sous-systeme_.ino (1.62 KB)

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.

...R

A typical very bed example of the Arduino Forum: 10 responds with no result.

RudolfAtRTC:
A typical very bed example of the Arduino Forum: 10 responds with no result.

What sort of thing would you consider to be a "result"

...R