Yes, you can. You need to have the right hardware for a motion sensor light. Typically, there is a separate sensor from the light fixture that will sense motion and trigger the light to turn on when you enter the closet. In sensor mode, you won’t need to use the light switch.