Get rid of the PIR. You can get the compiler to help you with this again. Delete this line:
const byte sensor = 6; // PIR sensor pin SENSOR REPLACED BY TRIGGER
Compile and fix the resulting errors by deleting the PIR related stuff it finds.
Then take this if and it's body and move it so it executes when distance is less than the desired minimum:
if ( isActivated == false ) {
A