added code for photo interrupter