2

I tried to imitate lagsilva's clock projects using Arduino Uno and made the circuitry, then I've tried to upload the main source code of the author but noticed that it didn't work, so I've edited the sketch and modified some of the details. When uploading it to the board, it seemed fine but there was nothing on the board and the project. Here are the codes:

Lagsilva's:

/*  4-Stroke Digital Clock With Two MAX72XX LED Matrix & RTC
              V1.1 - 02.Feb.2018
               Author: LAGSILVA */

     #include <LedControl.h>                   // Library for LED Matrix - MAX72XX
#include <Wire.h>                         // Library for DS3231 - Pins of Arduino UNO: A4 (SDA), A5 (SCL)
#include <DS3231.h>                    // Library for Real Time Clock    
// Global Variables
byte hh, mm;                              // Hour, Minute
byte uH, uM, dH, dM;                      // Units Hour, Units Minute, Teens Hour, Teens Minute
byte p = 0;                               // Plot Mode (Position of Digits: Up/Down)
int RPM = 0, lastRPM = 0, pinRPM = 0;     // RPM, Last value of RPM, Analog Pin for RPM
byte seq = 1;                             // Start Fire sequence

/*
  Pin numbers do Arduino para conexao com o MAX72XX (matriz de LED com controlador MAX72XX)
  pin 7 is connected to the DataIn (DIN)
  pin 6 is connected to LOAD (CS)
  pin 5 is connected to the CLK (CLK)
*/

LedControl lc = LedControl(7, 5, 6, 2);  // LedControl(int DIN, int CLK, int CS, int numDevices)


// Array of Digits - (0 to 9) - Size 5x3

byte num[10][3] = {

  {0xF8, 0x88, 0xF8}, // 0
  {0x00, 0xF8, 0x40}, // 1
  {0xE8, 0xA8, 0xB8}, // 2
  {0xF8, 0xA8, 0x88}, // 3
  {0x78, 0x20, 0xE0}, // 4
  {0xB8, 0xA8, 0xE8}, // 5
  {0xB8, 0xA8, 0xF8}, // 6
  {0xC0, 0xB8, 0x80}, // 7
  {0xF8, 0xA8, 0xF8}, // 8
  {0xF8, 0xA0, 0xE0}, // 9

};


void setup() {

  setSyncProvider(RTC.get);    // Function to read RTC (Real Time Clock)
  //setSyncInterval(3600);                // Set the number of seconds between re-sync
  //setTime(14, 59, 00, 03, 02, 2018);    // Set the Time and Date
  //RTC.set(now());                       // Set the RTC time

  // Setup of Display "0"
  lc.shutdown(0, false);                // Wakeup Display "0"
  lc.setIntensity(0, 4);                // Set the Brightness of Display (0 to 15)
  lc.clearDisplay(0);                   // Clear Display "0"

  // Setup of Display "1"
  lc.shutdown(1, false);                // Wakeup Display "1"
  lc.setIntensity(1, 4);                // Set the Brightness of Display (0 to 15)
  lc.clearDisplay(1);                   // Clear Display "1"

}


void loop() {

  hh = (11);
  mm = (14);

  uH = hh % 10;
  dH = hh / 10;

  uM = mm % 10;
  dM = mm / 10;


  // Plot Hours

  for (byte k = 0; k < 3; k++) {

    lc.setRow(0, k + 5, num[dH][k] >> (p + 2));
    lc.setRow(0, k + 1, num[uH][k] >> (3 - p));

  }


  // Plot Minutes

  for (byte k = 0; k < 3; k++) {

    lc.setRow(1, k + 4, num[dM][k] >> (3 - p));
    lc.setRow(1, k , num[uM][k] >> (p + 2));

  }


  // Plot Fire Sequence: 1-3-4-2 (4 cyl: 1-3-4-2 or 1-2-4-3 or 1-4-3-2)

  if (seq == 1) {                               // Fire Cyl #1
    lc.setLed(0, 6, 0, true);
  }

  if (seq == 2) {                               // Fire Cyl #3
    lc.setLed(1, 5, 0, true);
  }

  if (seq == 3) {                               // Fire Cyl #4
    lc.setLed(1, 1, 0, true);
  }

  if (seq == 4) {                               // Fire Cyl #2
    lc.setLed(0, 2, 0, true);
  }

  seq = seq % 4 + 1;


  // RPM reading

  RPM = analogRead(pinRPM);                     // Potentiometer reading

  RPM = map(RPM, 0, 1023, 1, 9);

  if (RPM <= 8) {
    lc.setLed(1, 7, 8 - RPM, true);
    lc.setLed(0, 0, 8 - RPM, true);
    delay(300 / RPM);                           // Speed setup by potentiometer (100 - 800 RPM)

    if (lastRPM != RPM) {
      lc.setRow(0, 0, 0);
      lc.setRow(1, 7, 0);
      lastRPM = RPM;
    }

  }

  p = !p;                                       // Switch the position of digits (Up x Down)


}

My modification was this:

#include <Wire.h>
#include <DS3231.h>
#include <LedControl.h>
// Global Variables
byte hh, mm;                              // Hour, Minute
byte uH, uM, dH, dM;                      // Units Hour, Units Minute, Teens Hour, Teens Minute
byte p = 0;                               // Plot Mode (Position of Digits: Up/Down)
int RPM = 0, lastRPM = 0, pinRPM = 0;     // RPM, Last value of RPM, Analog Pin for RPM
byte seq = 1;                             // Start Fire sequence

LedControl lc = LedControl(7, 5, 6, 2);  // LedControl(int DIN, int CLK, int CS, int numDevices)


// Array of Digits - (0 to 9) - Size 5x3

byte num[10][3] = {

  {0xF8, 0x88, 0xF8}, // 0
  {0x00, 0xF8, 0x40}, // 1
  {0xE8, 0xA8, 0xB8}, // 2
  {0xF8, 0xA8, 0x88}, // 3
  {0x78, 0x20, 0xE0}, // 4
  {0xB8, 0xA8, 0xE8}, // 5
  {0xB8, 0xA8, 0xF8}, // 6
  {0xC0, 0xB8, 0x80}, // 7
  {0xF8, 0xA8, 0xF8}, // 8
  {0xF8, 0xA0, 0xE0}, // 9

};


void setup() {


  //setSyncInterval(3600);                // Set the number of seconds between re-sync
  //setTime(19, 07, 59, 06, 03, 2018);    // Set the Time and Date
  //DS3231.set(now());                       // Set the RTC time

  // Setup of Display "0"
  lc.shutdown(0, false);                // Wakeup Display "0"
  lc.setIntensity(0, 4);                // Set the Brightness of Display (0 to 15)
  lc.clearDisplay(0);                   // Clear Display "0"

  // Setup of Display "1"
  lc.shutdown(1, false);                // Wakeup Display "1"
  lc.setIntensity(1, 4);                // Set the Brightness of Display (0 to 15)
  lc.clearDisplay(1);                   // Clear Display "1"

}


void loop() {

  hh = (21);
  mm = (32);


  uH = hh % 10;
  dH = hh / 10;

  uM = mm % 10;
  dM = mm / 10;


  // Plot Hours

  for (byte k = 0; k < 3; k++) {

    lc.setRow(0, k + 5, num[dH][k] >> (p + 2));
    lc.setRow(0, k + 1, num[uH][k] >> (3 - p));

  }


  // Plot Minutes

  for (byte k = 0; k < 3; k++) {

    lc.setRow(1, k + 4, num[dM][k] >> (3 - p));
    lc.setRow(1, k , num[uM][k] >> (p + 2));

  }


  // Plot Fire Sequence: 1-3-4-2 (4 cyl: 1-3-4-2 or 1-2-4-3 or 1-4-3-2)

  if (seq == 1) {                               // Fire Cyl #1
    lc.setLed(0, 6, 0, true);
  }

  if (seq == 2) {                               // Fire Cyl #3
    lc.setLed(1, 5, 0, true);
  }

  if (seq == 3) {                               // Fire Cyl #4
    lc.setLed(1, 1, 0, true);
  }

  if (seq == 4) {                               // Fire Cyl #2
    lc.setLed(0, 2, 0, true);
  }

  seq = seq % 4 + 1;


  // RPM reading

  RPM = analogRead(pinRPM);                     // Potentiometer reading

  RPM = map(RPM, 0, 1023, 1, 9);

  if (RPM <= 8) {
    lc.setLed(1, 7, 8 - RPM, true);
    lc.setLed(0, 0, 8 - RPM, true);
    delay(300 / RPM);                           // Speed setup by potentiometer (100 - 800 RPM)

    if (lastRPM != RPM) {
      lc.setRow(0, 0, 0);
      lc.setRow(1, 7, 0);
      lastRPM = RPM;
    }

  }

  p = !p;                                       // Switch the position of digits (Up x Down)


}

The schematic diagram

Anyone could help me please, thank you!

  • 1
    If you try a default / example sketch, high likely there is a problem in your circuit. First try a/the default sketch for an 8x8 matrix separately, than the other, than you can continue with this more 'advanced' sketch. – Michel Keijzers Mar 8 '18 at 14:46
  • 1
    I have doing this project for a week or so and repeatedly checked if there are errors in the circuit I might got, and based on (I think) 7-10 times of checking the schematic diagram, there are no errors on the circuit. Okay sir, I'll try. Thank you! – Charles Alison Mar 8 '18 at 14:52
  • 1
    run the example sketch for the martix – Juraj Mar 8 '18 at 15:01
  • 1
    LedControl lc = LedControl(7, 5, 6, 2); // LedControl(int DIN, int CLK, - your picture is not in line with this entry. Pin 7 connected to CLK on the picture, and your code say CLK line connected to pin 5. And you claim you have checked your wiring? – smajli Mar 8 '18 at 16:13
  • 1
    @smajli Sir, when I saw the changes in the codes and in the diagram, I've changed immediately the wirings on my arduino board. – Charles Alison Mar 8 '18 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.