https://www.kernel.org/doc/html/v5.0/driver-api/gpio/index.h...
You can usually find libraries for your language of choice to speak GPIO and expose the pin's state as a variable in your code.