I often use a timer loop to read sensors. I've attached some code, which compiles, however I don't have the sensor.
BTW. I am assuming it is a single shot IR sensor that returns 0 if something is detected.
int out1 = 5; //motor
int IRSensor = 3; // connect ir sensor to arduino pin 6
int LED = 6; // conect Led to arduino pin 9
int Switch = 2;
As I understood you want the motor to run only while you are pressing the button, stopping as you release the button. IR remote controls normally don't send a "release" signal. But they often send a "repeat" signal in a defined frequency. The value of this signal depends on the remote, that you use. A quick search showed this forum thread, where the value is ...