help conecting two devices

hey , maybe you can use PIR sensor, and you can set the range of detection(about 10cm-7m).