https://raspberrypihq.com/use-a-push-button-with-raspberry-pi-gpio/#:~:text=Connecting the Raspberry Pi's general,pin 1 using a resistor. does this help? you can also search for how to connect float switches to pi. or check the design of dfrobot's photoelectric sensor breakout board.
It's more of a software question than a how to connect the wiring question.
- If the software uses the internal pull UP resistor, I will need to ground the input to give it a state change
- If the software uses the internal pull DOWN resistor, I will need to raise the input to vcc (with a current limiting resistor) to give it a state change
- If no internal pullups are set in software than I can use an external pull up or pull down resistor and the above cases will apply, (except that the on and off signal will only be correct in one case.)
BTW, I'm not using any hats / shields breakout boards, I want to connect direct to the GPIO
The physically connecting part is easy.
But what Reef Pi does with the result is unclear.
From your example I assume that you are using the internal pull-down? Is that correct?
/DM


