Digital control allows you to set the volume of the amplifier using a microcontroller via I2C protocol. The I2C data pins are connected on a breakout at the bottom of the board.

Assembling Breakout Headers


You can solder wires directly to the breakout pads but its easier to prototype if there are headers attached. Follow along to attach headers!
The easiest way to attach headers to the breakout board is to take advantage of a solderless breadboard you may have.
Break off a piece of 0.1" male header, 14 pins long and stick it long pins down into the solderless breadboard
This will keep it in place when you put the audio amplifier on top! Put the breakout board onto the short header pins so they stick out thru the breakout pads
Solder in all of the header pins to the breakout board.

Connecting up to an Arduino


We'll be using an Arduino to test the digital control, but really the I2C protocol is so simple, you can easily port the code to any microcontroller you like.

First, though, we'll have to wire up the digital data pins.

Connect the following header pins:
  • GND from the MAX9744 connects to the common ground connection on your Arduino
  • Vi2c from the MAX9744 connects to the logic level voltage of your board. For most Arduinos, 5V works well. If you have a 3V microcontroller, use 3.3V
  • Connect the SDA pin to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2
  • Connect the SCL pin to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
If you want to use I2C volume control, do not solder in the potentiometer
Make sure the AD1 AD2 and Analog solder jumpers are not closed before running the I2C tests, or it won't work! For digital mode, these jumpers must be un-soldered

Run code


Since the MAX9744 has pretty much no protocol for sending data other than "write the volume level you want" we didn't write a library, just an example sketch as shown below

Upload this sketch to your Arduino, and keep it connected to your computer. Don't forget to power the MAX9744 with 5-12VDC separately via the DC jack!
#include <Wire.h>

// 0x4B is the default i2c address
#define MAX9744_I2CADDR 0x4B

// We'll track the volume level in this variable.
int8_t thevol = 31;

void setup() {
  Serial.begin(9600);
  Serial.println("MAX9744 demo");
  Wire.begin();
  
  if (! setvolume(thevol)) {
    Serial.println("Failed to set volume, MAX9744 not found!");
    while (1);
  }
}


// Setting the volume is very simple! Just write the 6-bit
// volume to the i2c bus. That's it!
boolean setvolume(int8_t v) {
  // cant be higher than 63 or lower than 0
  if (v > 63) v = 63;
  if (v < 0) v = 0;
  
  Serial.print("Setting volume to ");
  Serial.println(v);
  Wire.beginTransmission(MAX9744_I2CADDR);
  Wire.write(v);
  if (Wire.endTransmission() == 0) 
    return true;
  else
    return false;
}

// Read in + and - characters to set the volume.
void loop() {
  if (! Serial.available()) return;
  
  // read a character from serial console
  char c = Serial.read();
  
  // increase
  if (c == '+') {
    thevol++;
  }
  // decrease
  else if (c == '-') {
    thevol--;
  }
  // ignore anything else
  else 
    return;
    
  if (thevol > 63) thevol = 63;
  if (thevol < 0) thevol = 0;

  setvolume(thevol);
}
Run the sketch and open up your Arduino Serial console. If there's a problem you'll get a failure to set the volume initially
If it's OK, you can send multiple +'s and -'s to increase or decrease the volume. The volume can go down to 0 or up to 63 (which is 29dB of gain)

Changing the I2C address


if you need to change the address from the 0x4B default to something else, you can close the AD1 or AD2 jumpers but not both to change the address to 0x4A (AD1 closed or tied to ground) or 0x49 (AD2 closed or tied to ground)

Connecting to a Raspberry Pi or BeagleBone Black

If you'd like to control the MAX9744 from a Raspberry Pi or BeagleBone Black then check out this Adafruit MAX9744 Python library.  The readme for the library has instructions on connecting to the board, installing the library, and demonstrating the usage with an example.  Using this library you can set the volume and increase or decrease it using Python and an I2C connection from your board.

This guide was first published on Mar 12, 2014. It was last updated on Mar 12, 2014.

This page (Arduino Digital Control) was last updated on Mar 12, 2014.

Text editor powered by tinymce.