my code is only doing void setup

long startTime ;                    // start time for stop watch
long elapsedTime ;
int preincrementation = 8;
int vrai = 9;
 

float prevtension;// global variables are retained on each iteration of loop()
float time;
int valeurLue;

int analogPin = A0;
const int led =  13; 
float tension; //variable pour stocker la valeur lue après conversion


void setup() {
pinMode(analogPin, INPUT);
  pinMode( led, OUTPUT ); 
  digitalWrite(led, HIGH); 
       delayMicroseconds (200000);
       digitalWrite(led, LOW); // 2.5cm
       Serial.begin(9600);

}



void loop() {
prevtension = tension;
  
  valeurLue = analogRead(analogPin);

	//on traduit la valeur brute en tension (produit en croix)
	tension = valeurLue * 5.0 / 1024;
  float RPMactuel = 60000000  / elapsedTime;
 float initime = 0.04 * elapsedTime;
  float RPMconsigne = 3000;
  float consigne = 60000000 / RPMconsigne;
  
 if (tension < 2.55)
  {if (tension < (prevtension - 0.005)) {  // compare them
        elapsedTime =   micros() - startTime;   
        startTime = micros(); 
      digitalWrite(led, HIGH); 
      
       if(elapsedTime > consigne)
       {time = initime;} // 4%
       
       if(elapsedTime < consigne)
       {time = 4;
 if ( (consigne - (consigne * 0.02)) < elapsedTime < (consigne + (consigne * 0.02)))
       digitalWrite (preincrementation, HIGH);
      { if ( elapsedTime < consigne )
     {
   
   if ( elapsedTime > (consigne - (consigne * 0.0001)) )
   {time = 4;
   time += 0.001;}
   if ( elapsedTime < (consigne + (consigne * 0.0001)) )
   {time = 4;
   time -= 0.001;}
 
  if ((consigne - (consigne * 0.0001)) < elapsedTime < (consigne + (consigne * 0.0001)))
{digitalWrite (vrai, HIGH);}}   }
       
       delayMicroseconds (time);
       digitalWrite(led, LOW); // do something, they are different
{if (tension > 2.54 && tension < (prevtension - 0.005)) {digitalWrite(led, LOW);}
  } }
    }
 }
 
   
   
   Serial.print("elapsedTime = ");
	Serial.println(elapsedTime);
   Serial.print("consigne = ");
	Serial.println(consigne);
   Serial.print("rpm actuel = ");
	Serial.println(RPMactuel);
  Serial.print("rpm consigne = ");
	Serial.println(RPMconsigne);
Serial.print("initime = ");
	Serial.println(initime);
Serial.print("time = ");
	Serial.println(time);




Serial.println();
     Serial.println();
      
}

my code is only doing void setup why

It's such a mess I can't see what's what, for example that the heck is this

{if (tension > 2.54 && tension < (prevtension - 0.005)) {digitalWrite(led, LOW);}
  } }
    }
 }

Hint: Use the formatting tool in the IDE (^T) and the code might be readable.

Put a print() at the top of loop(), if that works move it down through your code until it doesn't work, that's the problem area.


Rob

it does look as if some of those times are a bit long, 60000000?

<<Use the formatting tool in the IDE (^T) and the code might be readable.>>

what it mean

take a look at the first paragraph of this
http://arduino.cc/en/Reference/DelayMicroseconds

and IDE (^T) is do ctrl t whilst in your sketch, it cleans it up line wise.

so you suggest me to use to use the other delay

Did you read that text?

Currently, the largest value that will produce an accurate delay is 16383. This could change in future Arduino releases. For delays longer than a few thousand microseconds, you should use delay() instead.


Rob

yea, delay() might work better the micro is only accurate to 16383 you have 6000000 and the present sketch you have would be a lot easier to read if it was formatted better.
Did you try ctrl T ?
Also putting print() statements in like graynomad says is a good bug finding technique

ok but how the delay will know that the value is in microseconds

       delayMicroseconds (200000);

Firstly delayMicroseconds takes an unsigned int, and 200000 is out of range,
secondly delayMicroseconds doesn't work at all for large arguments,
keep the values passed between 0 and a few 1000.

but those the delay works if i enter
delay(200000)
will he undertand that it is 0.2 secondes

but it seems that hes not considering the second condition why

Jhjh:
<<Use the formatting tool in the IDE (^T) and the code might be readable.>>

what it mean

it mean:-
go to the Edit menu and click on Select All
go to the Tools menu and click Auto Format

No need to even select the text. Just go to the Tools menu and click Auto Format will do.

Jhjh:

long startTime ;                    // start time for stop watch

long elapsedTime ;
int preincrementation = 8;
int vrai = 9;

float prevtension;// global variables are retained on each iteration of loop()
float time;
int valeurLue;

int analogPin = A0;
const int led =  13;
float tension; //variable pour stocker la valeur lue après conversion

void setup() {
pinMode(analogPin, INPUT);
  pinMode( led, OUTPUT );
  digitalWrite(led, HIGH);
       delayMicroseconds (200000);
       digitalWrite(led, LOW); // 2.5cm
       Serial.begin(9600);

}

void loop() {
prevtension = tension;
 
  valeurLue = analogRead(analogPin);

//on traduit la valeur brute en tension (produit en croix)
tension = valeurLue * 5.0 / 1024;

float RPMactuel = 60000000  / elapsedTime;
float initime = 0.04 * elapsedTime;
  float RPMconsigne = 3000;
  float consigne = 60000000 / RPMconsigne;
 
if (tension < 2.55)
  {if (tension < (prevtension - 0.005)) {  // compare them
        elapsedTime =   micros() - startTime;   
        startTime = micros();
      digitalWrite(led, HIGH);
     
       if(elapsedTime > consigne)
       {time = initime;} // 4%
       
       if(elapsedTime < consigne)
       {time = 4;
if ( (consigne - (consigne * 0.02)) < elapsedTime < (consigne + (consigne * 0.02)))
       digitalWrite (preincrementation, HIGH);
      { if ( elapsedTime < consigne )
     {
   
   if ( elapsedTime > (consigne - (consigne * 0.0001)) )
   {time = 4;
   time += 0.001;}
   if ( elapsedTime < (consigne + (consigne * 0.0001)) )
   {time = 4;
   time -= 0.001;}

if ((consigne - (consigne * 0.0001)) < elapsedTime < (consigne + (consigne * 0.0001)))
{digitalWrite (vrai, HIGH);}}   }
       
       delayMicroseconds (time);
       digitalWrite(led, LOW); // do something, they are different
{if (tension > 2.54 && tension < (prevtension - 0.005)) {digitalWrite(led, LOW);}
  } }
    }
}

Serial.print("elapsedTime = ");
Serial.println(elapsedTime);
   Serial.print("consigne = ");
Serial.println(consigne);
   Serial.print("rpm actuel = ");
Serial.println(RPMactuel);
  Serial.print("rpm consigne = ");
Serial.println(RPMconsigne);
Serial.print("initime = ");
Serial.println(initime);
Serial.print("time = ");
Serial.println(time);

Serial.println();
     Serial.println();
     
}





my code is only doing void setup why

Here in you code Delay provided in setup()is very high. If you want blink led for particular time use timer library.If you can explain What are trying to acheive here, can reduce COde also.