multiplexing with an i2c device?

I have 4 transistors I'd like to switch on and off to send power to one of 4 different speakers.

If I were using arduino, I'd simply control each of those transistors with 4 pins, however, I'm using a different open source datalogger, and I am out of pins to power the transistors. I do have an I2C bus, and I'm curious if there is an IC that can be controlled by I2C that will let me replicate what the arduino does (turning pins high/low to run the transistor).

I am NOT looking for the TCA i2c multiplexer, as this lets me run multiple different i2c buses. I'm just trying to work aroudn the fact I don't have enough pins to run all 4 transistors. I only have one spare analog pin, or the I2C bus.

Any thoughts on where to start?

You are driving one leg of the speaker, and have other connected to Gnd?

Drive all the speakers in parallel, and use an N-channel MOSFET as a switch to connect to Gnd.
Then a part like this can be used to turn the selected speaker's MOSFET on.
https://www.digikey.com/en/products/detail/microchip-technology/MCP23008-E-P/735951

Since it is comparatively slow and tedious to toggle outputs on a port expander and driving speakers will presumably require frequent switching to generate audio tones, I would suggest using a port expander to perform some of the other functions you are using to free up Arduino pins for the speakers.

Here is a ready-built port expander module.

Aliexpress link

One or more (up to four) of these connects to your I2C interface.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.