remember duration

hi everyone Im trying to write a program that can remember the duration of a pressed button1 , and the second button switch the led for the same duration

#define Led 4
#define Pous1 2
#define Pous2 3
#define Pous1On (digitalRead(Pous1==0))
#define Pous2On (digitalRead(Pous2==0))
#define LedOn digitalWrite(Led,1)
#define LedOff digitalWrite(Led,0)
 void setup(){
 pinMode(Led,1);
  pinMode(Pous1,0);
   pinMode(Pous2,0); 
 } 
 void loop(){
 while(Pous1On){}
 //start time in millis()
 while(!Pous1On){}
 //stop time 
 //duration =time 
 if (Pous2On){
  // LedOn; delay( duration) ; LedOff;
 }
  }

Ditch the #defines, they are pretty close to pre-processor abuse. You define Pous1 as 2. What do you expect "Pous1==0" to return?

You want

while (digitalRead(Pous1) == 0)

I want to start a time with while (digitalRead(Pous1==0)) {} and while (digitalRead(!Pous1==0)) {} the time stop but when button 2 is clicked if (digitalRead(Pous2)==0) the led is ON for a duration =(time) Thanks..

I know what you are trying to do, but your clunky defines hid the fact that your

digitalRead(Pous1==0)

boils down to digitalRead(0)
which is not what you want.
You want

digitalRead(Pous1) == 0

Try to do this exercise. What the #define does is to make the write of the programs easier. After the program was compiled it writes what is at the right by what is at the left. So for the line:

#define Pous1On (digitalRead(Pous1==0))

replacing Pous1 it become:

#define Pous1On (digitalRead(2==0))

and the line:

while(Pous1On)

it becomes (replacing Pous1On):

while((digitalRead(2==0)))

This is wrong! What it should be was:

while ( ( digitalRead(2) == 0 ) )

Do you see the difference?

EDIT: There are many more errors! For example, this:

while(Pous1On){}

don't do nothing! Or better, waits until the button was pressed, but I don't think that in this case this can help.

whats wrong in the if statment ? yhe Led is always off I want to add a delay = duration btween On and off Thanks,

#define Led 4
#define Pous1 2
#define Pous2 3
 void setup(){
 pinMode(Led,1);
  pinMode(Pous1,0);
   pinMode(Pous2,0);
  Serial.begin(9600); 
 } 
long StartTime ;
long duration;
 void loop(){

 while(!digitalRead(Pous1)==0){ StartTime = millis();}
 while(digitalRead(Pous1)==0){ duration=millis()-StartTime;}

 if (digitalRead(Pous2)==0){
 digitalWrite(Led,HIGH);
 delay(duration);
 digitalWrite(Led,LOW);
 }
  }

The if don't work because you don't wait until the second key is pressed, and then the program goes to the begin of the loop again. But I think that all the concept is wrong.

But it should work if you put something like:

while(digitalRead(Pous2)!=0);

before the if statement.

obrigado luisilva :D it works

Yes I know it works. You say "thanks", but I don't see more karma points! :(

Im so sorry Im new in this forum I didnt know it , until u told me