If You don't know how it works, then You cannot write a program for it.
What You should look for is data-sheet of a sensor, there You should get an explanation of what signal it outputs to microcontroller.
If You tell us what sensor You are using, then we have better chances of guiding You to the correct direction.