# Is anyone using hardware buttons to control play/pause through the GPIO pins?

**URL:** <https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069>\
**Category:** Pi MusicBox (archive)\
**Created:** [January 23, 2016, 8:59am UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069 "2016-01-23T08:59:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DarkHelmet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/darkhelmet/32/732_2.png) [@DarkHelmet](https://discourse.mopidy.com/u/DarkHelmet)\
**Post date:** [January 23, 2016, 8:59am UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069/1 "2016-01-23T08:59:37Z")

</div>

I have built my Pi Zero running Pi MusicBox into an antique radio and can control the volume by using a digital rotary encoder (sending volume commands to Alsamixer). This is working fine.

Now I want to use the push/click function of the rotary encoder to play/pause Pi Musicbox. There are 2 separate pins on the rotary encoder just for the push/click function but I don’t know what software changes I need to make in Pi MusicBox or Mopidy to make this work.

Has anyone connected hardware push switches to the GPIO pins to control play/pause or maybe previous/next functions?

---

<div class="post-metadata">

**Author:** ![jodal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/jodal/32/2651_2.png) [@jodal](https://discourse.mopidy.com/u/jodal)\
**Post date:** [January 24, 2016, 8:19pm UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069/2 "2016-01-24T20:19:59Z")

</div>

You don’t need to modify Mopidy to make that happen. Mopidy lets you control it either through the MPD protocol using e.g. the python-mpd client library in your GPIO-reading application or through HTTP or WebSocket. Check out the Mopidy docs for the details!

---

<div class="post-metadata">

**Author:** ![DarkHelmet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/darkhelmet/32/732_2.png) [@DarkHelmet](https://discourse.mopidy.com/u/DarkHelmet)\
**Post date:** [January 24, 2016, 9:09pm UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069/3 "2016-01-24T21:09:01Z")

</div>

Thanks for answering. I guess that a gpio reading application is what I actually need. I found the Mopidy-TtsGpio add-on which seems to do what I need (and more): [https://github.com/9and3r/mopidy-ttsgpio/blob/master/README.rst](https://github.com/9and3r/mopidy-ttsgpio/blob/master/README.rst)

I’ll try that.

---

<div class="post-metadata">

**Author:** ![advhound](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/advhound/32/1263_2.png) [@advhound](https://discourse.mopidy.com/u/advhound)\
**Post date:** [January 31, 2016, 11:35pm UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069/4 "2016-01-31T23:35:19Z")

</div>

I too have built a vintage radio retrofitted with a Raspberry Pi. There are 2 knobs on the radio. One is wired directly to the amplifier to control the volume, and I would like to use the other knob to select pre-defined audio sources like Spotify playlists, online radio (NPR) and podcasts. I believe this would be accomplished by using a rotary encoder and wiring this to GPIO on the Raspberry Pi. I could use some help with the software/programming to make this happen? Thank you!

---

<div class="post-metadata">

**Author:** ![DarkHelmet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/darkhelmet/32/732_2.png) [@DarkHelmet](https://discourse.mopidy.com/u/DarkHelmet)\
**Post date:** [February 1, 2016, 6:07am UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069/5 "2016-02-01T06:07:04Z")

</div>

So far I was only able to use a rotary encoder as digital volume controller. For other functions I’m still trying. Also check out this thread: [Control With buttons or screen?](https://discourse.mopidy.com/t/control-with-buttons-or-screen/306/38)

---

<div class="post-metadata">

**Author:** ![BaconWithThat](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@BaconWithThat](https://discourse.mopidy.com/u/BaconWithThat)\
**Post date:** [February 1, 2016, 7:28pm UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069/6 "2016-02-01T19:28:42Z")

</div>

I’m in the middle of a project that uses GPIO to start specific playlists when a pushbutton is pressed. I have a python script running a loop that looks for GPIO inputs and then sends a few commands via os.system to mpc. I have it running on boot by adding a line to Cron, as detailed here: [http://embeddedday.com/projects/raspberry-pi/a-step-further/running-python-script-at-boot/](http://embeddedday.com/projects/raspberry-pi/a-step-further/running-python-script-at-boot/)

Here’s my current code: [http://pastebin.com/NFNpvjEH](http://pastebin.com/NFNpvjEH). onyeabor and katamari are 2 named playlists i have created. I wish there was a good way to create and manipulate playlists in one of the web extensions, but that doesn’t seem to exist anywhere i’ve seen yet.

---

<div class="post-metadata">

**Author:** ![hulkhaugen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/hulkhaugen/32/365_2.png) [@hulkhaugen](https://discourse.mopidy.com/u/hulkhaugen)\
**Post date:** [March 17, 2016, 10:58pm UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069/7 "2016-03-17T22:58:48Z")

</div>

I’m new to this whole thing, but i’m planning to use a Pi and Amp+ to supply a ceiling speaker in my new bathroom. I’m thinking that (on)-off spring-loaded light switch could do four things. Shot press would be on/off or play/pause, while long press would be vol+/vol-, kinda like an electronic dimmer. I guess i’ll have to learn some python scripting to pull this off… (unless it already exists?)

---

<div class="post-metadata">

**Author:** ![jodal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/jodal/32/2651_2.png) [@jodal](https://discourse.mopidy.com/u/jodal)\
**Post date:** [February 19, 2026, 11:47am UTC](https://discourse.mopidy.com/t/is-anyone-using-hardware-buttons-to-control-play-pause-through-the-gpio-pins/1069/8 "2026-02-19T11:47:29Z")

</div>

Closed on February 19, 2026, 11:47am UTC


