The "one button ON-OFF" switch function has been built into the Raspberry Pi device tree since July, 2017. All that's really required is two pieces of wire, but a momentary push-button switch can be added if you wish - perhaps your "three pin switch" can serve in this role?
One Button?
Let me explain in the following schematic what is meant by "one button ON-OFF" function, as there has been some confusion on this point:

simulate this circuit – Schematic created using CircuitLab
Two items of note:
- While no software is required to implement the one-button-ON/OFF feature, the device tree overlay shown below must be added to the file
/boot/config.txt
(for bullseye
& earlier), or the file boot/firmware/config.txt
(for bookworm
& later):
at the command prompt, open the file for editing:
$ sudo nano /boot/config.txt # bullseye & earlier
# OR...
$ sudo nano /boot/firmware/config.txt # bookworm & later
once the file is open, add the following line of text:
dtoverlay=gpio-shutdown,gpio_pin=3
- The RPi will cease processing in the "OFF" state, but will continue to draw power. As of this writing, reaching a "ZERO POWER" state for all RPi models may be achieved only by "pulling the plug".
Background
Matthijs Kooijman developed the dtoverlay
for gpio-shutdown
. His blog post discusses his motivation, and provides some details: "Raspberry pi powerdown and powerup button". If you're interested in the source code for this particular dtoverlay, you can find that here in the RPi GitHub repo.
While the overlay allows the user to specify any GPIO, only GPIO 3 (the default) allows one to shutdown and startup using the same single button. If the user selects a different GPIO, the user may shutdown the RPi, but a startup requires a power cycle - i.e. unplug the power cord & plug it in again. And finally, on the subject of power, know that the RPi will continue to draw power even after the shutdown. The power consumption will be reduced, but not eliminated.