How to program with multiple sensors?

I am new in using arduino and programming and right now I am doing a project that uses multiple sensors under different conditions. These are:

1 ultrasonic sensor to light an LED when a certain distance is reached.
2 PIR motion sensor to light an LED for each one according on which PIR was triggered by a movement.

Individually, they work when I run them but when I combine the code, it doesn't work the way I want. Can someone please help me? My code is right below.

Smart_Helmet.ino (3.49 KB)

it doesn't work the way I want.

What does it do? What do you want it to do?

Your code for triggering the ultrasonic sensor is not the usual code for doing that. You are waiting far too long to turn the trigger pin back off.

The delay() on EVERY pass through loop() simply guarantees unresponsive code.

  val = digitalRead(inputPin);     // read input value

Meaningless names. What is connected to the pin? The name should reflect that.

Your code would be a LOT easier to follow, if it was properly indented. Use Tools + Auto Format to do that.

My mistake sir. I'm sorry and thank you for correcting me. To explain what my project is supposed to be a smart helmet for bicycle users. It's function includes:
-anti-collision using ultrasonic sensor that will trigger a light signal using an LED in front of the helmet when a certain distance is reached.
-2 PIR sensors placed on the left and right side of the helmet that will trigger a light signals in the back of the helmet to know whether the cyclist is turning right or left. (this will work the same as the signal lights in cars when they u-turn)

As for this

val = digitalRead(inputPin);     // read input value

It was designated for the PIR sensors 1 and 2 which I failed to properly declare. Now I declare it like this

pinMode(inputPin, INPUT);   //input on left Pir
pinMode(inputPin2, INPUT);  //input on right pir

However, I have a problem understanding this.

The delay() on EVERY pass through loop() simply guarantees unresponsive code.

As a newbie I am only basing my codes on basic tutorials thats why I'm having difficulties this.

-anti-collision using ultrasonic sensor that will trigger a light signal using an LED in front of the helmet when a certain distance is reached.

If the rider can't see the object that is within range of the ultrasonic sensor (usually a fairly short distance), what good will the light do?

-2 PIR sensors placed on the left and right side of the helmet that will trigger a light signals in the back of the helmet to know whether the cyclist is turning right or left.

How will the presence, or absence, of a warm-blooded animal (including humans) to the left or right of the wearer mean anything with respect to what the wearer of the helmet is going to do?

Now I declare it like this

You still have to read from the correct pins, then.

However, I have a problem understanding this.

Suppose that every time the minute hand on your watch moved, you took a 55 second nap. Would you EVER get anything done? There is NOTHING in your code that requires a delay. Get rid of the call.

If the rider can't see the object that is within range of the ultrasonic sensor (usually a fairly short distance), what good will the light do?

The Purpose of the light is to alarm the cyclist of an approaching vehicle so maybe he can increase the speed or move on the roadside to make way to the approaching vehicle.

How will the presence, or absence, of a warm-blooded animal (including humans) to the left or right of the wearer mean anything with respect to what the wearer of the helmet is going to do?

I placed the sensor downwards to limit what the sensor can detect as on how effective it can be I still don't know. I'm still on the trial and error stage.

The Purpose of the light is to alarm the cyclist of an approaching vehicle so maybe he can increase the speed or move on the roadside to make way to the approaching vehicle.

Do you have a clue what the range of your ultrasonic sensor is? I don't think so. By the time the car is close enough for the ultrasonic sensor see, if the rider hasn't seen the car, the only blinking lights the rider is going to see are those on the ambulance transporting him to the hospital (or morgue).

I'm still on the trial and error stage.

More on the error stage, as I see it. A passive infrared sensor is completely the wrong kind of sensor to be using, if you expect it to tell you that a rider is turning.