Try it

Start with an LED and pushbutton, then replace the button with a sensor. Record what changes in the code and electrical circuit.