Hello
When a program that has been manipulating GPIO pins terminates, the state of the GPIO pins is typically reset. This is because the GPIO settings are held in the memory space of the program, and when the program ends, its memory space is cleaned up by the operating system.
The GPIO cleanup function in Python, for example, resets any ports you have used in the program back to input mode. This is a safety feature to prevent damage from a situation where you have a port set HIGH as an output and you accidentally connect it to GND (LOW), which would short-circuit the port and possibly fry it.
If you want the GPIO settings to persist after the program has ended, you would need to write a separate program or script that runs at startup and sets the GPIO pins to your desired state. This program would need to run every time the system starts up to ensure the GPIO pins are always set correctly.
However, please note that this is generally not recommended practice. The state of GPIO pins should be controlled by the program that is using them, and that program should clean up after itself when it’s done. This prevents conflicts between different programs trying to use the same GPIO pins and ensures that each program only changes the state of the GPIO pins it is using.