i2c controlled amplifier

I have for a while wanted to have some speakers out over my terrasse, and my surround receiver got multiple zones, but what if I want different volume levels?

Timing could not have been much better, just a few days after I started looking around for small amplifiers I could mount a stepper to to control volume, or opto to simulate key presses, adafruit posted a new device… A little 20w class D amplifier, with i2c!!!

Next up was to find a way to remote control it, and as I had a few Electric Imp’s laying around, this was an obvious choice… Biggest problem with this was that there were no tutorial on how to do this, and with my totally lack of experience with i2c, I had to turn to the Electric Imp forum, and a few members came to the rescue!

To control the amplifier from an Electric Imp, I can now use this code

hardware.i2c89.configure(CLOCK_SPEED_400_KHZ);
function setVolume(_volume) {

    local address   = 0x4B <<1;
    local volume = _volume;
    if (volume > 63)
    {
        volume = 63;
    }
    else if (volume < 0)
    {
        volume = 0;
    }

    hardware.i2c89.write(address, format("%c%c", volume>>8, volume&0xff));
}

setVolume(35);

And so far the only word I have found for this, is AWESOME! 😀

Leave a Reply