When you try to spot or hear any lurking foes or find evidence of a hidden trap or a secret door, you will usually be asked to make a Wisdom (Perception) check. This check measures the keenness of your senses (sight, hearing, touch, smell, or taste). (82) Go here for examples.
Describe your search in detail. This may render a check unnecessary.
Poor lighting, fog, and other obstructions may give you disadvantage on your perception check. Moving at a fast pace can also give you disadvantage.
Natural obstructions may limit how far you can see.
There are limitations on how far you can hear.
Passive perception. You may also be able to detect a hidden foe, trap, door, etc., even when you are not actively searching. See passive Wisdom (Perception) check. Go here for an example.
Using intelligence. Sometimes your senses alone will not be enough. When you look around for clues and make deductions based on those clues, you may be asked to make an Intelligence (Investigation) check. (81) Go here for examples.
In other situations your recollection of historical, religious, or nature-based lore may enable you to discern the presence of a secret door, trap, or other hidden thing. In such situation a lore-based Intelligence check would be appropriate. (81) Go here for examples.
You can attempt an Intelligence (Arcana) check to detect a magic trap, in addition to any other check noted in the trap's description. (195) Go here for examples.
Using magic. Sometimes you can use spells or magic items to discover hidden things or to improve your ability check to find something.
Search action required? If you want to devote your attention to finding something during combat, then you will have to take the Search action. (94) House rule: during combat you can make a "quick glance" without using up your action.