Using MQTT and rpi_gpio together

Hey guys, is it possible to configure Home Assistant to use a switch that’s connected to a GPIO pin on the Raspberry Pi to publish to mqtt? I know how to configure a switch for either mqtt or rpi_gpio however I want to combine the two if you know what I mean.

This could help

Thanks. I have no idea how this would integrate in my scenario though unfortunately (yep, I’m still pretty new to this).
My pi would have a pushbutton switch connected to a gpio. Same Pi is running broker and HA. Then I need to send mqtt publish to arduino when button is pushed. Really not sure how to tie this all together in the HA config file.