EspHome Raspberry pi GPIO

Can I configure a binary sensor on the Home Assistant Raspberry Pi GPIO?
Can Anyone share the code of it with me.

Thanks in Advance