Demo: Pass your hand over the SLIDER activating a device. Is this case the fish tank lamp
Autodesk Inventor Sketch
Here's the standard code:
Assign pin names
In the Setup section: assign input / output function.
In the loop section: detect motion; read the current state of the output from a string; switch the output to the opposite state:
On my Fish Tank project, instead motion turns the light on. A timer turns the lamp off again, shown here it turns off after running through the loop 5 times: