Go Down

Topic: MAX6959 and I2C (Read 1 time) previous topic - next topic

pylon

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

Code: [Select]

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:

Code: [Select]
// 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();
}

ichris93


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

Code: [Select]

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?
Code: [Select]


#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);
}

pylon

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

Code: [Select]
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();
}

ichris93

#8
Feb 11, 2013, 02:34 am Last Edit: Feb 11, 2013, 02:37 am by ichris93 Reason: 1

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

Code: [Select]
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.  

Go Up