MAX6959 and I2C

Hello all,

I am working on a project which requires a four digit seven segment display which is connected to my Arduino with a MAX6959 that interfaces with I2C. I can get all of the segments to light up with the following display test code.

#include <Wire.h>

void setup()
{
  Wire.begin(); 
}


void loop()
{
  Wire.beginTransmission(0b0111000); 
  Wire.write(0x07);
  Wire.write(0x01);  
  Wire.endTransmission();
}

But I can't figure out how to control the digits. Here is a link to the data sheet, http://datasheets.maximintegrated.com/en/ds/MAX6958-MAX6959.pdf

Thanks!

You can use the following code to set the value of every digit:

byte d[] = { 0x7e, 0x60, 0x6d, 0x79, 0x33, 0x5b, 0x1f, 0x70, 0x7f, 0x7b };
void set_digit(byte digit, byte value) {
  Wire.beginTransmission(0x38);
  Wire.write(0x20 + digit);
  Wire.write(d[value]);
  Wire.endTransmission();
}

I probably have the code setup wrong. But bellow is what I have and it isn't working. Thank you for your help.

#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}
byte d[] = { 0x7e, 0x60, 0x6d, 0x79, 0x33, 0x5b, 0x1f, 0x70, 0x7f, 0x7b };
void set_digit(byte digit, byte value) 
{Wire.beginTransmission(0x38);
  Wire.write(0x20 + digit);
  Wire.write(d[value]);
  Wire.endTransmission();
}

void loop()
{
 set_digit(0, 0);
}

But bellow is what I have and it isn't working.

The code does something. You haven't described that.
You want the code to do something. How that differs from what it does isn't clear.

The ball's back in your court.

PaulS:
The code does something. You haven't described that.
You want the code to do something. How that differs from what it does isn't clear.

The ball's back in your court.

When I send it that code, the display doesn't show anything. When I send it that code I would like it to display 0 on digit 0.

You should have tried with another digit, because digit 0 is in decode mode by default. Insert the following into your setup routine:

Wire.beginTransmission(0x38);
Wire.write(0x01); // register decode mode
Wire.write(0x00); // disable decode mode for all digits
Wire.endTransmission();

A short description what the set_digit() routine does:

// array holding the bitsets for displaying digits 0 to 9
// see page 9, figure 10 of the datasheet for the segment numbering
byte d[] = { 0x7e, 0x60, 0x6d, 0x79, 0x33, 0x5b, 0x1f, 0x70, 0x7f, 0x7b };

void set_digit(byte digit, byte value) {
  Wire.beginTransmission(0x38); // address the MAX6959
  Wire.write(0x20 + digit); // register 0x20 is digit 0, 0x21 is digit 1, etc.
  Wire.write(d[value]); // write the value from the array to the register.
  Wire.endTransmission();
}

pylon:
You should have tried with another digit, because digit 0 is in decode mode by default. Insert the following into your setup routine:

Wire.beginTransmission(0x38);

Wire.write(0x01); // register decode mode
Wire.write(0x00); // disable decode mode for all digits
Wire.endTransmission();

Even with the following code, nothing happens. What am I doing wrong?

#include <Wire.h>
byte d[] = { 0x7e, 0x60, 0x6d, 0x79, 0x33, 0x5b, 0x1f, 0x70, 0x7f, 0x7b };

void setup()
{
  Wire.begin();
  Wire.beginTransmission(0x38);
  Wire.write(0x01); // register decode mode
  Wire.write((uint8_t)0x00); // disable decode mode for all digits
  Wire.endTransmission();
}

void set_digit(byte digit, byte value) 
{
  Wire.beginTransmission(0x38);
  Wire.write(0x20 + digit);
  Wire.write(d[value]);
  Wire.endTransmission();
}

void loop()
{
  set_digit(3, 1);
}

Let's extend setup to be sure that all registers have a valid content:

void setup()
{
  Wire.begin();
  Wire.beginTransmission(0x38);
  Wire.write(0x01); // register decode mode
  Wire.write(0x00); // disable decode mode for all digits
  Wire.write(0x3f); // intensity max
  Wire.write(0x03); // scan limit 3
  Wire.write(0x03); // normal operation
  Wire.endTransmission();
}

pylon:
Let's extend setup to be sure that all registers have a valid content:

void setup()

{
 Wire.begin();
 Wire.beginTransmission(0x38);
 Wire.write(0x01); // register decode mode
 Wire.write(0x00); // disable decode mode for all digits
 Wire.write(0x3f); // intensity max
 Wire.write(0x03); // scan limit 3
 Wire.write(0x03); // normal operation
 Wire.endTransmission();
}

Great!! Thank you! That finally has it working. BUT you have 0X60 for 1 and it should be 0X30 and for 6 you have 0X1F and it should be 0X5F.