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!
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
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); }
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.