Mobile Sensors OH

Please expand your question and tell us what exactly you are trying to do.

Which phone? Which OS? Which sensors?

Have you looked at Tasker?