infrared sensor, buzzer and motor

Hello, how can I do a program that, when it detects a movement, the motor stops and sounds like an infrared barrier for safety?

You can't. Because you haven't described for example what infrared sensor is being used, how the Motor is controlled or how you want to generate sounds.

People may understand "please yell loudly" but Computers certainly do not. Computers ask silly questions like "how do I yell and can you please define 'loud'".

Please read the post entitled "How to use this forum - please read." found at the top of each Forum area and restate your question.