A mosfet seems pretty overkill for this instead of practically any cheaper transistor unless there’s something about motherboard headers I don’t know. Pretty cool though.
I had this particular MOSFET lying around from a different project, so that’s the main reason I chose that one :)
> void press(){ digitalWrite(PWRBTN, HIGH); delay(33); digitalWrite(PWRBTN, LOW); delay(33); digitalWrite(PWRBTN, HIGH); }
My 5min hack would look like this - and optionally a 0.1uF and a 1k resistor for peace of mind - totally untested though. Usually a uC I/O pin has three states; output high, output low and Hi-Z. Hi-Z is high-impedance or extremely high resistance state, analogous to an open circuit.