Speaker PHAT mute switch

I wanted to add an on/off switch to the Speaker-Phat for my Pi Zero W to be a hardware mute button.
I was wondering what the safest and simplest way to do that would be? i.e. what two or three pins would I connect the switch to on the GPIO pins on the front of the Speaker-Phat?

A soft-mute (a python script that calls alsamixer) is probably the easiest option. Find any free GPIO pin on your Pi, and a Ground pin, then connect an SPDT switch across them so that in one position it shorts that GPIO pin to ground.

Set up the GPIO pin as an input/pullup and it will read 1/HIGH until the switch is closed. You can then use an event detect in RPi.GPIO to wait for it to go 0/LOW and trigger the mute, then wait for 1/HIGH to umute.

We’ve got a product in the works with push-buttons that might be just the ticket. You’ve actually given me a great idea for a useful example to ship with it :D

Hi. Thanks for writing back and for the suggestion. Yes, I’ve written button-driven GPIO scripts for the PI in the past. I was hoping for a more direct HW-oriented way.

I love the Speaker PHAT but I wish it had a volume knob at the very least or music control buttons. I am in the process of hooking up a rotary encoder/push button to control the volume and mute on mine. It will also serve as light-dimmer for my WiFi LED bulbs.

I’m glad I could help inspire you with examples haha. I will be more than happy to test any prototype you have for the push-button board if you have any to spare.

this is an illustration of calling amixer to affect volume in software:

it is called by the python-based daemon written for Picade HAT, but there is no reason why it couldn’t be called another way. Or modify it to mute rather than increase/decrease the overall volume.

Is there a way to short one of the i2s pins to have a hardware mute switch?