how to toggle two outputs?

newbie has a problem.

Normally both OUTputs are LOW. If button is pressed (high), turn OUT1 to high for 2 seconds, If button is pressed once again, turn OUT2 to high for 2 seconds. Loop.

Had no success with millis(), which function should i use?

Millis is the function you should use. Post what you tried and we can see if we can spot where you went wrong.

Try this code :

const int buttonPin = 2;    // the number of the pushbutton pin
const int OUT_1 = 13;       // output 1 pin
const int OUT_2 = 12;       // output 2 pin

int buttonState;             // the current reading from the input pin
int lastButtonState = HIGH;   // the previous reading from the input pin

long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time in miliseconds; increase if the output flickers
byte press_counter = 0;     // variable to store number of button presses
int time1_counter = 0;
int time2_counter = 0;
long previousMillis = 0;     // timer variable to count timer for OUTPUT_1 change

const byte OUTPUT_TIME = 2;    // time in seconds ,for each  output to stay HIGH, Change to whatever you like

void setup()
{
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(OUT_1, OUTPUT);
  pinMode(OUT_2, OUTPUT);

  digitalWrite(OUT_1, LOW);
  digitalWrite(OUT_2, LOW);
}

void loop()
{
  ///////////////////////////////////////////////////////////////////////////////   time measuring
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= 1000)  // this part is measuring time and increasing time1 and time2 conters every second
  {
    time1_counter ++;
    time2_counter ++;
    previousMillis = currentMillis;
  }
  if ( time1_counter > OUTPUT_TIME )            // make sure to not overflow counter
  {
    time1_counter = 0;
    time2_counter = 0;
  }
  ////////////////////////////////////////////////////////////////////////////// button debouncing
  int reading = digitalRead(buttonPin);
  // check to see if you just pressed the button
  // (i.e. the input went from HIGH to LOW),  and you've waited
  // long enough since the last press to ignore any noise:

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState)
  {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay)
  {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState)
    {
      buttonState = reading;

      // only increase counter if the new button state is LOW
      if (buttonState == LOW)
      {
        press_counter ++ ;
      }
    }
  }
  ///////////////////////////////////////////////////////////////////////////////////////////
  if ( press_counter == 1 && buttonState == LOW )
  {
    digitalWrite(OUT_1, HIGH);
    time1_counter = 0;
  }

  if ( press_counter >= 2 && buttonState == LOW )
  {
    digitalWrite(OUT_2, HIGH);
    time2_counter = 0;
    press_counter = 0;
  }

  if ( time1_counter >= OUTPUT_TIME )            // make uutput 1 pin LOW after desired time
  {
    digitalWrite(OUT_1, LOW);
  }

  if ( time2_counter >= OUTPUT_TIME )            // make uutput 2 pin LOW after desired time
  {
    digitalWrite(OUT_2, LOW);
  }

  lastButtonState = reading;
}

Connect your button to pin 2 and GND. Output pins are 13 and 12. This code includes button debouncing. If button reacts to quickly ( introducing some noise ) increase this to 60... 150

long debounceDelay = 50;

Hi ruklis. As Mike suggested, you are best to post your attempt in the forum rather than asking someone to give you the code - to help your learning. Simply highlight your sketch in Arduino, C, then in this forum in a reply, pick the “Code” button above and V. Here’s a little hint that might get you thinking one of many solutions…

void loop() {
  if ( step == 1 && digitalRead(buttonPin) == LOW) {
    digitalWrite(OUT_1, HIGH);
    delay(2000);
    digitalWrite(OUT_1, LOW);
    step = 2;
  }

  if ( step == 2 && digitalRead(buttonPin) == HIGH) {

Guys, you are awesome- I started to study the code you have posted.

Below is my old code, I was missing the [previous button state] monitoring.

 const int buttonPin = 3;
 int buttonState = 0;
 const int aPin = 13;
 const int bPin = 12;

 
long previousMillis = 0;       

long interval = 1000;           

void setup() 
{                
  
   // initialize the digital pin as an output.
   pinMode(aPin, OUTPUT); 
   pinMode(bPin, OUTPUT);

   pinMode(buttonPin, INPUT);  // initialize the pushbutton pin as an input

}

void loop()
{ 
    previousMillis = millis();
   // read the state of the pushbutton value:
   buttonState = digitalRead(buttonPin);
  
   
  
    if(buttonState == HIGH && (millis() - previousMillis < interval)) {      
          digitalWrite(aPin, HIGH);
          delay (2000);
          digitalWrite(aPin, LOW);
        
    }
          else if(buttonState == HIGH && (millis() - previousMillis > interval)) {      
          digitalWrite(bPin, HIGH);
          delay (2000);
          digitalWrite(bPin, LOW);
      }   
   }

Your on the right track. Now see if you can drop in another condition in your if statement that qualifies that you will turn on aPin. At the end of that statement, invert that variable. Then loose the else statement. Make another similar if statement with the inverted new condition to run bPin. I suggest you put in a Serial.println statement to check if you get errors.