HELP PLEASE - Combining 2 Simple (but having issues )Sketches

Hello,

I am new to all this. I am wondering if anyone can provide assistance in combining the following two sketches please. Basically the system is that an LED lights up when PIR motion detector is activated and holds ledPin10 on for 20 secs. In addition if the ultrasonic sensor detects within less than 100cm then a separate output is activated by means of LedPin11, this LED is then held on for 10 seconds. I did kind of manage to do it earlier but the ‘delays’ meant that my system would not sense until the LED’s turned off; however I have now messed around with that script and cant think how I even got there. Many thanks if anyone cant help!

const int ledPin= 10;
const int inputPin= 2;

void setup(){
pinMode(ledPin, OUTPUT);
pinMode(inputPin, INPUT);
}

void loop(){
int value= digitalRead(inputPin);

if (value == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(20000);
digitalWrite(ledPin, LOW);
}
else
{
digitalWrite(ledPin, LOW);
}
}

and

#define trigPin 13
#define echoPin 12
#define led 11

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
}

void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 4) {
digitalWrite(led,HIGH);
delay(10000)
}
else {
digitalWrite(led,LOW);
}
if (distance <= 100){
Serial.println(“Warning”);
}
else {
Serial.print(distance);
Serial.println(" cm");
}
delay(500);
}

The delays will interfere with eachother. Try implementing interrupts or millis().