How to control different pin at the same time?

I need to control different output pin at the same time. How can I do that?

What exactly are you trying to do?

Define 'at the the same time' .

.

is this what you want? https://www.arduino.cc/en/Reference/PortManipulation

I must control a lamp for example for 5 hours and during this time I must control an eletctric motor 1min “HIGH” and 4 minutes “LOW”. I don’t know how I can do that at the same time

Try to understand the blink with out delay example that comes with the IDE.

Also find Robin2's thread how to do several things at the same time.

Here is an example to toggle two LEDs using the BWD technique.

Use it as a stepping stone to do more than one thing at a time.

/*
  GetRidOfDelay.ino
  LarryD
  Version YY/MM/DD
  1.00    17/02/01  Running code

*/

//LED wiring:
// +5V---220 ohm resistor---LED anode---LED cathode---Arduino pin

const unsigned long heartBeatDelay = 100UL;
const byte heartBeatLED            = 13;    //used to see if the sketch is blocking
const byte myLED                   = 12;    //wired so a LOW turns the LED on

unsigned long currentMillis;
unsigned long heartBeatMillis;
unsigned long myLEDmillis;
unsigned long waitTime = 1000; //every 1 second

//                          s e t u p ( )
//**********************************************************************
void setup()
{
  pinMode(heartBeatLED, OUTPUT);

  pinMode(myLED, OUTPUT);
  digitalWrite(myLED, HIGH);        //HIGH is LED off

} //                 E n d  o f  s e t u p ( )

//                          l o o p ( )
//**********************************************************************
void loop()
{
  currentMillis = millis(); //for milli second timing

  //***************************
  //HeartBeat LED, should toggle every heartBeatDelay milliseconds if code is nonblocking
  if (currentMillis - heartBeatMillis >= heartBeatDelay)
  {
    heartBeatMillis = heartBeatMillis + heartBeatDelay; //reset timing

    //Toggle heartBeatLED
    digitalWrite(heartBeatLED, !digitalRead(heartBeatLED));
  }

  //***************************
  usingMillis();


} //                    E n d  o f  l o o p ( )

//======================================================================
//                        F U N C T I O N S
//======================================================================


//                     u s i n g M i l l i s ( )
//**********************************************************************
void usingMillis()
{
  //is it time to do something with myLED
  if (currentMillis - myLEDmillis < waitTime)
  {
    //No, it is not time
    return;
  }
  //Yes, it is time
  myLEDmillis = currentMillis;      //reset timing

  //toggle myLED
  digitalWrite(myLED, !digitalRead(myLED));

}//                E n d  o f  u s i n g M i l l i s ( )

//======================================================================
//                        E N D  O F  C O D E
//======================================================================

yes, Blink Witout Delay is a similar program but I don't understand if I can change the time delay in that sketch. As far I've understood the delay can't be changed, so it will ever be a normal blink. I must control a motor that is "HIGH for 1 minute and "LOW" for 4 minutes. How can I do that?? D: I hope my english is quite correct

The demo Several Things at a Time is an extended example of BWoD and illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Your program can change any of the intervals anytime it wants to.

...R

Tia1997:
yes, Blink Witout Delay is a similar program but I don’t understand if I can change the time delay in that sketch. As far I’ve understood the delay can’t be changed, so it will ever be a normal blink. I must control a motor that is "HIGH for 1 minute and “LOW” for 4 minutes. How can I do that?? D:
I hope my english is quite correct

Example how to change timing:

//LED wiring:
// +5V---220 ohm resistor---LED anode---LED cathode---Arduino pin

const byte heartBeatLED = 13;    //used to see if the sketch is blocking
const byte myMotor      = 12;    //wired so a LOW turns the Motor off (use driver transistor)

//****************************************

unsigned long currentMillis;
unsigned long heartBeatMillis;
const unsigned long heartBeatDelay = 100UL;

//****************************************
//for minutes swap the comments // below

// minutes example
//unsigned long highTime = 4 * 60 * 1000ul; //every 4 minutes
//unsigned long lowTime  = 1 * 60 * 1000ul; //every 1 minutes

// seconds example
unsigned long highTime = 4 * 1000ul; //every 4 second
unsigned long lowTime  = 1 * 1000ul; //every 1 seconds

//****************************************

byte delayFlag = true;    //true enables 4 second/minute, false enables 1 seconds/minutes
unsigned long motorMillis;
unsigned long motorTime   = highTime;

//****************************************



//                          s e t u p ( )
//**********************************************************************
void setup()
{
  pinMode(heartBeatLED, OUTPUT);

  pinMode(myMotor, OUTPUT);
  digitalWrite(myMotor, LOW);        //HIGH is motor OFF

} //                 E n d  o f  s e t u p ( )

//                          l o o p ( )
//**********************************************************************
void loop()
{
  currentMillis = millis(); //for milli second timing

  //***************************
  //HeartBeat LED, should toggle every heartBeatDelay milliseconds if code is nonblocking
  if (currentMillis - heartBeatMillis >= heartBeatDelay)
  {
    heartBeatMillis = heartBeatMillis + heartBeatDelay; //reset timing

    //Toggle heartBeatLED
    digitalWrite(heartBeatLED, !digitalRead(heartBeatLED));
  }

  //***************************
  myMotorFunction();


} //                    E n d  o f  l o o p ( )

//======================================================================
//                        F U N C T I O N S
//======================================================================


//                         m y M o t o r F u n c t i o n ( )
//**********************************************************************
void myMotorFunction()
{
  //Is it time to do something with myMotor
  if (currentMillis - motorMillis < motorTime)
  {
    //No, it is not time
    return;
  }
  //Yes, it is time
  //reset timing
  motorMillis = currentMillis; 

  if (delayFlag == true)
  {
    //Motor LOW time
    delayFlag = false;         
    //change the delay time to lowTime
    motorTime = lowTime;
    digitalWrite(myMotor, LOW); //motor OFF
  }

  else
  {
    //Motor HIGH time
    delayFlag = true;
    //change the delay time to highTime
    motorTime = highTime;
    digitalWrite(myMotor, HIGH); //motor ON
  }


}//End of          m y M o t o r F u n c t i o n (  )

//======================================================================
//                        E N D  O F  C O D E
//======================================================================

Edit:
Updated code

Tia1997: I must control a lamp for example for 5 hours and during this time I must control an eletctric motor 1min "HIGH" and 4 minutes "LOW". I don't know how I can do that at the same time

How are you controlling the lamp? Is the Arduino measuring 5 hours for you? How do you think your program should work? Not using delay is what all the examples are trying to show you, so where are you seeing a problem?