Introduction: Digital Clock Project Using 8 Digit 7 Segment MAX7219 Module

Picture of Digital Clock Project Using 8 Digit 7 Segment MAX7219 Module

8 Digit 7 Segment MAX7219 Module is an amalgamation of two pieces of 0.56" 4 Display 7 Segment Common Cathode Module which is mounted or arranged horizontally and controlled by MAX7219 driver. The advantages of this module is that it only takes 3 pins of I/O as a communication on arduino, so as to minimize the use of arduino I/O pins. This module can be applied to various projects that require character display, especially numeric characters, for example: Digital Clock Project.

Specification of 8 Digit 7 Segment MAX7219 Module:

  • Power Supply : 5VDC
  • Data Interface : SPI Serial (Din & Dout)
  • 7 Segment Color : Red
  • 7 Segment : 8 Digit
  • Driver : MAX7219

There are 5 Pins of Interface:

  • VCC : 5VDC
  • GND : 0V / Ground
  • DIN : Data IN / SDA / MOSI
  • CS : Shift / SS
  • CLK : Clock / SCK

DOUT allows you to add 7 Segment Module to the number as needed.

As we mentioned before, this module can be applied to -one of them- Digital Clock Project. Here is an example project to display time (hour, minute, and second) and date (day, month, and year) alternately.

Step 1: Materials You Need

Picture of Materials You Need

You will need:

  1. 8 Digit 7 Segment MAX7219 Module
  2. SFE Duino CH340
  3. RTC I2C DS1307 Module
  4. Male to Female Jumper Wires
  5. Male to Male Jumper Wires

Step 2: Setup

Picture of Setup

Connect 8 Digit 7 Segment MAX7219 Module, SFE Duino CH340, and RTC I2C DS1307 Module with jumper wires as schematic above or configuration pin below:

  • CLK = 2 SDA = A4
  • CS = 3 SCL = A5
  • DIN = 4 VCC = 5V
  • GND = 0V GND = 0V
  • VCC = 5V

Step 3: Code

Picture of Code

First, download the library below. After that, input it on library of Arduino IDE.

Libraries

Insert the library on Arduino IDE sketch program. Enter the example of sketch below. Then upload the program.

#include <RTClib.h>
#include <LedControl.h>
//=======================================================================================
// data pin, clock, latch

double hold;

LedControl lc = LedControl(4, 2, 3, 1);
RTC_DS1307 rtc;

//========================================================================================

void setup() {
rtc.begin();
lc.shutdown(0, false);
lc.setIntensity(0, 8); // display brightness
lc.clearDisplay(0); // erase display
//rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); //set clock as computer clock
//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

}

//========================================================================================
void loop() {
hold = millis();
while ((hold + 20000) > millis() ) {
DateTime now = rtc.now();
setCol1(now.hour());
setCol2(now.minute());
setCol3(now.second());
lc.setChar (0, 2, '-', false);
lc.setChar (0, 5, '-', false);
}

hold = millis();
while ((hold + 5000) > millis() ) {
DateTime now = rtc.now();
setCol1(now.day());
setCol2(now.month());
setCol3(now.year() - 2000);
lc.setChar (0, 2, '-', false);
lc.setChar (0, 5, '-', false);
}

}

//========================================================================================
void setCol1 (byte jam) {
String strBuffer = Konversi(jam);
byte pjg = strBuffer.length() + 1;
char val[pjg];
strBuffer.toCharArray(val, pjg);
lc.setChar (0, 0, val[0], false);
lc.setChar (0, 1, val[1], false);
}

//========================================================================================
void setCol2 (byte mnt) {
String strBuffer = Konversi(mnt);
byte pjg = strBuffer.length() + 1;
char val[pjg];
strBuffer.toCharArray(val, pjg);
lc.setChar (0, 3, val[0], false);
lc.setChar (0, 4, val[1], false);
}

void setCol3 (byte dtk) {
String strBuffer = Konversi(dtk);
byte pjg = strBuffer.length() + 1;
char val[pjg];
strBuffer.toCharArray(val, pjg);
lc.setChar (0, 6, val[0], false);
lc.setChar (0, 7, val[1], false);
}

String Konversi(int nilai) {
if (nilai < 10) {
return "0" + String(nilai);
}
else {
return String(nilai);
}
}

Step 4: Try It!

Picture of Try It!

After the program successfully uploaded, the 8 Digit 7 Segment Module will display clock display like the picture above.

It will display hours, minutes, and seconds for 20 seconds, then it will automatically change to display day, month, and year for 5 seconds, and so on.

Step 5: Check the Video to Know More

Comments

About This Instructable

549views

3favorites

License:

Bio: Electronics Component - PCB [Design, Printing, Inserting] - Electronic Programming
More by sfeelectronics:Display Temperature on P10 LED Display Module Using ArduinoKeypad Access 4x4 With ArduinoDisplay Text at P10 LED Display Using Arduino
Add instructable to: