Single Push Push Button Flip Flop

Hi, is it possible to make a flip flop circuit via just one push-button in the software?
ie. press a button and an output comes on, press the same button again and the output goes off.

Sure, assuming the program is actively running. This would not work if the robot was just idle.

image

All your really need is the stuff in the thread.

Thank You.
I’ve bought a latching relay, as it needs to work Independant of the robot state.
Thanks.