• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Making a Digital Clock : Arduino 7 Segment 4 Digit TM1637

By Abhishek Ghosh February 14, 2017 10:59 pm Updated on February 14, 2017

Making a Digital Clock : Arduino 7 Segment 4 Digit TM1637

Advertisement

Previously, we talked about 7 Segment 4 Digit TM1637 Display. In This Guide We Will Be Making a Digital Clock With Arduino 7 Segment 4 Digit TM1637 Display Unit. It is important to read the linked guide. We are including circuit diagram and code for completing the project. Total cost will be of Arduino, 7 Segment 4 Digit TM1637 display (around $3), one DS3231 Real Time Clock Module ($1.5) and three push buttons (few cents), one breadboard (normally we have), few jumpers. It is costly in terms of electronics.

 

Making a Digital Clock : Arduino 7 Segment 4 Digit TM1637 and DS3231 RTC Module

 

In the above linked guide we told you that for real time clock (RTC), we need another chip. That DS3231 real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar. The clock can operate in either the 24-hour or 12-hour format with AM/PM indicator, but the library only supports the 24-hour mode. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. We need the below library for TM1637 :

Vim
1
http://www.seeedstudio.com/wiki/File:DigitalTube.zip

You can watch the video of what exactly going to happen :

Advertisement

---

Vim
1
https://www.youtube.com/watch?v=JyIqXafq9eg&feature=youtu.be

 

Making a Digital Clock With Arduino 7 Segment 4 Digit TM1637

 

That video provided the non-English language website who essentially provided the code.

Making a Digital Clock - Arduino 7 Segment 4 Digit TM1637

 

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <Wire.h>
#include "TM1637.h"
#define CLK 6        
#define DIO 7
#define brightness 6
#define keyHor 5
#define keyMin 4
#define keyPL  3
 
TM1637 tm1637(CLK,DIO);  
#define DS3231_I2C_ADDRESS 0x68
  
volatile boolean flag;
 
byte decToBcd(byte val){
  return ( (val/10*16) + (val%10) );
}
 
byte bcdToDec(byte val){
  return ( (val/16*10) + (val%16) );
}
 
void setDateDs3231(byte second,  
                   byte minute,        // 0-59
                   byte hour,          // 1-23
                   byte dayOfWeek,     // 1-7
                   byte dayOfMonth,    // 1-28/29/30/31
                   byte month,         // 1-12
                   byte year)          // 0-99
{
   Wire.beginTransmission(DS3231_I2C_ADDRESS);
   Wire.write(0);
   Wire.write(decToBcd(second));    
   Wire.write(decToBcd(minute));
   Wire.write(decToBcd(hour));    
   Wire.write(decToBcd(dayOfWeek));
   Wire.write(decToBcd(dayOfMonth));
   Wire.write(decToBcd(month));
   Wire.write(decToBcd(year));
   Wire.endTransmission();
}
 
void getDateDs3231(byte *second,
          byte *minute,
          byte *hour,
          byte *dayOfWeek,
          byte *dayOfMonth,
          byte *month,
          byte *year)
{
 
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0);
  Wire.endTransmission();
 
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
 
  *second     = bcdToDec(Wire.read() & 0x7f);
  *minute     = bcdToDec(Wire.read());
  *hour       = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek  = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month      = bcdToDec(Wire.read());
  *year       = bcdToDec(Wire.read());
}
 
void setINT(){  
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0x0E);
  Wire.write(0x0);
  Wire.endTransmission();
}
 
void blink() {
  digitalWrite(13, !digitalRead(13));
  flag = !flag;
  tm1637.point(flag);
}
 
void setup() {
//  Serial.begin(9600);
  Wire.begin();
  pinMode(13, OUTPUT);
  pinMode(keyHor, INPUT_PULLUP);
  pinMode(keyMin, INPUT_PULLUP);
  pinMode(keyPL, INPUT_PULLUP);
 
  tm1637.init();
  tm1637.set(brightness);  
  
  setINT();
  attachInterrupt(0, blink, CHANGE);
}
 
void loop(){
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  getDateDs3231(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  int8_t TimeDisp[4];
  
  TimeDisp[0] = hour / 10;
  TimeDisp[1] = hour % 10;
  TimeDisp[2] = minute / 10;
  TimeDisp[3] = minute % 10;
 
  if (!digitalRead(keyHor) && !digitalRead(keyPL)){  
      second = 0;    
      hour++;  
      if (hour > 23) hour = 0;  
      setDateDs3231(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
      delay(200);
  }
  if (!digitalRead(keyMin) && !digitalRead(keyPL)){   // минуты
      second = 0;
      minute++;
      if (minute > 59) minute = 0;
      setDateDs3231(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
      delay(200);
  }
 
  tm1637.display(TimeDisp);
  
}

Here is the gist of the above code in unmodified form.

Tagged With TM1637 , tm1637 clock , arduino tm1637 clock , tm1637 arduino clock , picbasic write to tm1637 , tm1637 with rtc , arduino 7 segment clock , arduino seven segment clock , arduino 7 segment tm1637 , DS3231 on 4 digit display
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Making a Digital Clock : Arduino 7 Segment 4 Digit TM1637

  • Arduino 7 Segment LED Display Tutorial (TM1637 4 Digit)

    Here is Detailed Arduino 7 Segment LED Display Tutorial For the Beginners With Example Codes, Circuit Diagram Which Uses TM1637, Has 4 Digit.

  • Cheapest Arduino LED Clock With Arduino Clone at $8

    Here is Cheapest Arduino LED Clock Which With Arduino Clone Will Cost $8 To You. It Is Really Usable LED Clock For Any Purpose, Not For Fun.

  • Arduino 7 Segment LED Display Temperature Sensor (TM1637 & DHT11)

    Circuit, Code To Build Temperature Sensor For Air-conditioned Car With Arduino 7 Segment LED Display TM1637 & Cheap DHT11 Temperature Sensor.

  • List of Budget Saving Cheap Arduino Modules And Components

    Here Is Best List of Budget Saving Cheap Arduino Modules And Components on Web With Which You Can Create Useful Projects And Will Not Repent.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy