0

I found this sketch online and would like to reuse it. I do have a dot-matrix-display, that is accessable through an i2c with the address 0x70. How do I change the code to be able to use the hardware address instead of the Data, Load and CLK pins?

#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>
#include "LedControl.h"

//Pin definition constants
const int mDataIn=12, mLoad=11, mClk=10;  //Max7219 LED matrix

int h1, h2, m1, m2, s1, s2; // Each digit
int tChange; //Scratch used during change time via pushbutton

// Matrix library instance
LedControl lc=LedControl(mDataIn, mClk, mLoad,1); //Pin assignments and number of matrices (1)

void setup() {

  // Notify Arduimo that the RTC is the external time provider
  setSyncProvider(RTC.get);   

  //Initialize the MAX72XX in power-saving mode.
  lc.shutdown(0,false);
  lc.setIntensity(0,1); // Set brightness to a low value
  lc.clearDisplay(0); // Clear the display
  delay(100); // Wait after initializing display

  Serial.begin(9600);
}

void loop() {

  //Isolate hours, minutes, seconds, one digit to each LED matrix column.
  h1=n1(hour());
  h2=n2(hour());
  m1=n1(minute());
  m2=n2(minute());
  s1=n1(second());
  s2=n2(second());

  // Cast as (change integer to) byte, write to LED row.
  // (Row runs from pin to pin on model used.)
  lc.setRow(0,7,byte(h1));
  lc.setRow(0,6,byte(h2));
  lc.setRow(0,4,byte(m1));
  lc.setRow(0,3,byte(m2));
  lc.setRow(0,1,byte(s1));
  lc.setRow(0,0,byte(s2));
  }


  int n1(int num) {  // Function to isolate first digit of 2-digit integer
    num = num / 10; //Integer division by 10 (discard remainder)
    return num;
  }

  int n2(int num) {  // Function to isolate second digit of 2-digit integer
    num = num % 10; //Modulo division by 10 (keep remainder only)
    return num;
  }

1 Answer 1

1

How do I change the code to be able to use the hardware address instead of the Data, Load and CLK pins?

That is not possible as this is two totally different LED drivers. MAX72XX uses a protocol with those signals, while the dot-matrix LED display uses I2C.

You can always port the library to the dot-matrix. Or rewrite the sketch with the dot-matrix library.

Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.