Helping about sumobot programming

I was investigating in the forum about a Sumobot´s programming. However i didn´t found what i wanted so i decided open a new topic about it.

I have the IR program :

int ir1 = 2;

void setup() {
Serial.begin(9600);
pinMode(ir1; INPUT);
}

void loop() {
int estado = digitalRead(ir1);
Serial.println(estado);

delay(1);
}

The Ultrasoinc sensors:

long distancia; //distancia= distance
long tiempo;  // tiempo= time
int m1=10; //m1 here is a led
void setup() {
 Serial.begin(9600);
pinMode(9,OUTPUT);
pinMode(8,INPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}

void loop() {
 digitalWrite(9,LOW);
 delayMicroseconds(10);
 digitalWrite(9,HIGH);
 delayMicroseconds(20);
 digitalWrite(9, LOW);
 tiempo=pulseIn(8,HIGH);
 distancia=int(0.017*tiempo);
  Serial.println("Distancia ");
 Serial.print(distancia);
 Serial.println(" cm");
  
    if (distancia<80&&distancia>0)
    { Serial.println ("Atack 12V");
      digitalWrite(m1,HIGH);
      
      }
  else
      {digitalWrite(m1,LOW);
      }
 } 
  delay(1000);
}

And it is now my program

int IRD=2, IRTI=3, IRTD=4, EDI=5, TDI=6, EDD=7, TDD=8, EI=9, TI=10, ED=11, TD=12, led=13, pul=14, MAI=15, MAD=16, MRI=17, MRD=18;
long distancia;
long tiempo;

void setup() {
Serial.begin(9600);
pinMode(2;INPUT);
pinMode(3;INPUT);
pinMode(4;INPUT);
pinMode(5;INPUT);
pinMode(6;OUTPUT);
pinMode(7;INPUT);
pinMode(8;OUTPUT);
pinMode(9;INPUT);
pinMode(10;OUTPUT);
pinMode(11;INPUT);
pinMode(12;OUTPUT);
pinMode(13;INPUT);
pinMode(14;INPUT);
pinMode(15;INPUT);
pinMode(16;INPUT);
pinMode(17;INPUT);
pinMode(18;INPUT);
pinMode(19;INPUT);
pinMode(20;INPUT);
enc=0;
}

void loop() {
int lb1 = digitalRead(IRD);
int lb2 = digitalRead(IRTI);
int lb3 = digitalRead(IRTD);
  
if ( digitalRead(pul)==HIGH && enc=0 )
   { digitalWrite(led==HIGH);
    delay(5000);
    enc=1;
   }
if (digitalRead(pul)==HIGH && enc=1)
  {digitalWrite(led==LOW);
  delay(100);
  enc=0;
  }
if (enc==1)  {  
  
 //program here!
 }
} 

void avanzar () {                     //forward
 digitalWrite(MRI==LOW);
 digitalWrite(MRD==LOW);
 delay(5);  
 digitalWrite(MAI==HIGH);
 digitalWrite(MAD==HIGH);
}

void giroizq () {                        //turnleft
  digitalWrite(MAI==LOW);
  digitalWrite(MRD==LOW);
  delay(5);
  digitalWrite(MRI==HIGH);
  digitalWrite(MAD==HIGH);
  }

void giroder () {                      //turnright
  digitalWrite(MRI==LOW);
  digitalWrite(MAD==LOW);
  delay(5);
  digitalWrite(MAI==HIGH);
  digitalWrite(MRD==HIGH);
  }

void retroceder () {                   //backward
 digitalWrite(MAI==LOW);
 digitalWrite(MAD==LOW);
 delay(5);  
 digitalWrite(MRI==HIGH);
 digitalWrite(MRD==HIGH);  
 }

IRD = IR forward
IRTI = IR BACK LEFT
IRTD = IR BACK RIGHT
EDI = ECHO forward left
TDI = TRIGGER forward left
EDD = ECHO forward right
TDD = TRIGGER forward right
EI = ECHO left
TI = TRIGGER left
ED= ECHO right
TD = TRIGGER right
MAI = motor forward left
MAD = motor forward right
MRI =motor backward left
MRD =motor backward right

Sorry for this but the acronym is in spanish for my classmates and teacher

I used:
3 CNY70
4 hc sr04
2 gearmotors
l298 dual h bridge
Arduino UNO

My problem is how to run the testings sensors simultaneously because if i use delay, the next function won’t start until the last function ends. In other words, how to test the IR sensors while motors are ON

Thank you.

Use millis(). The code doesn't seem to use much delay, so the code should all work together-just call each function periodically.

Thank you, is for a school project so i decide for a more simple program. However, could you give an example with millis()?

See the BlinkWithoutDelay example. You can also just call different functions repeatedly in the loop.