• 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

This Article Has Been Shared 671 Times!

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 Based Patient Monitoring : Overview

    Here is an Overview of F/OSS Arduino Based Patient Monitoring in Terms of Ease of Build, Cost, Features & Comparison With Proprietary.

  • DIY Robot Guitar & Piano Player : Arduino to EV3

    Though This Article on Arduino to EV3 DIY Robot Guitar & Piano Player We Want to Deliver An Introductory Idea On What Peoples Are Developing.

  • 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.

  • Breadboard & Breadboarding Basics : Before Arduino

    Arduino Possibly a Very Good Approach But Unless the Basics Like Breadboard & Breadboarding is Known, All Will Suck Money For Simple Stuffs.

  • DC Motor Buying Guide for DIY Electronics Projects

    In DIY Electronics Including Arduino, Types of DC Motors Can Confuse a Newbie. Here is a DC Motor Buying Guide for DIY Electronics Projects.

Additionally, 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

  • What Online Casinos Have No Deposit Bonus in Australia March 30, 2023
  • Four Foolproof Tips To Never Run Out Of Blog Ideas For Your Website March 28, 2023
  • The Interactive Entertainment Serving as a Tech Proving Ground March 28, 2023
  • Is it Good to Run Apache Web server and MySQL Database on Separate Cloud Servers? March 27, 2023
  • Advantages of Cloud Server Over Dedicated Server for Hosting WordPress March 26, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Making a Digital Clock : Arduino 7 Segment 4 Digit TM1637," in The Customize Windows, February 14, 2017, March 31, 2023, https://thecustomizewindows.com/2017/02/making-digital-clock-arduino-7-segment-4-digit-tm1637/.

Source:The Customize Windows, JiMA.in

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT