Can I start a motor after detecting the absence of any obstacle

I am doing a project where I need to detect the absence of any obstacle and on the blower and as soon as the blower(motor) is one's a valve must be opened can I do the entire process in one aurdino using subfunctions

Yes, probably.

This is a trivial issue for an Arduino once it is possible to provide it with the appropriate data. How do you propose to collect the data?

...R