How to stop detected after 5 seconds using ultrasonic sensor

Welcome syahira_zulkifli, what is your question, as it is asked It is hard to answer correctly. Posting links to the technical information on the hardware devices will help a lot. Can you post a schematic not a frizzy picture. I am assuming you are using an arduino Uno, is that correct. What relay?