Added irReading on direction function to the loop