IR sensor & digital read

Your code talks about a pushbutton but not an IR sensor. Perhaps that's your problem. Or perhaps your comments are completely wrong which doesn't exactly help us.

Please provide a link to the IR sensor you are using and how it is connected. There are many different things called IR sensors.

Steve