MAX6969 and Pulse Width Modulation

Today I decided to take the MAX6969 sample a step further using Pulse Width Modulation (PWM) to vary LEDs intensity.

I replaced the LEDs from previous version to obtain a more homogeneous result and the pin 10 from the Arduino is connected on /OE.

I also wrote a small function max_write() allowing to write a full word (16 bits) to the MAX6969 outputs. One thing I noticed is the necessity to take /OE HIGH on data writing to avoid artifacts on LEDs, which I’m not already very clear why they happen, since the latch should avoid them (see in next article).

int DIN = 13;
int CLK = 12;
int LE  = 11;
int _OE = 10;

void setup() {
  pinMode(DIN, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(LE , OUTPUT);
  pinMode(_OE, OUTPUT);
}

void clk() {
  digitalWrite(CLK, LOW);
  digitalWrite(CLK, HIGH);
}

void latch() {
  digitalWrite(LE, LOW);
  digitalWrite(LE, HIGH);
}

void max_write(word data) {
  digitalWrite(_OE, HIGH);
  word mask = 0x8000;
  for (char i = 0; i <; 16; i++) {
    digitalWrite(DIN, (data & mask) != 0x0000);
    clk();
    mask >;>;= 1;
  }
  latch();
  digitalWrite(_OE, LOW);
}

word data = 0x0001;
void loop() {
  max_write(data);
  for (int i = 255; i >;= 0; i--) {
    analogWrite(_OE, i);
    delay(5);
  }
  for (int i = 0; i <; 255; i++) {
    analogWrite(_OE, i);
    delay(5);
  }

  data <;<;= 1;
  if (data == 0x0800) {
    data = 0x0001;
    delay(3000);
  }
}

Here is the video showing the code in action. The three LEDs on the right are darker than the other ones, this is not due to the MAX6969 but to the LEDs them selves.

It was really a lot of fun to use the MAX6969 to blink those LEDs, the fact that PWM is working makes it a good choice for light effects like an arc reactor for example …

One Reply to “MAX6969 and Pulse Width Modulation”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.