Maybe you can use the parking sensor example http://www.mysensors.org/build/parking