Arduino RTC LED clock



Arduino LED (RTC) Clock with Seconds and AM/PM indicator , 12/24 hr changing switch





First You have to download following libraries (link is given end of this page)

1. Wire.h
2. RTClib.h


Parts List





Watch the video




This is the RTC clock Module


This is the Arduino Circuit


RTC Wiring Connections




RTC Switches



Circuit Diagram (COMMON ANODE)

IF YOU USE COMMON CATHODE LED DO THE CHANGES AS FOLLOWS


POWER SUPPLY


Download Code File


Download Library Files





This is the code



/*
 4 digit 7 segment display: http://www.sparkfun.com/products/9483
 Datasheet: http://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AR6B-35.pdf
  */
// modified connexion by niq_ro from http://nicuflorica.blogspot.com
// dataseet: http://www.tme.eu/ro/Document/dfc2efde2e22005fd28615e298ea2655/KW4-563XSA.pdf
// Code modified by BMIAK Basnayaka
// http://www.arduinomyprojects.blogspot.com

int digit1 = 11; 
int digit2 = 10;
int digit3 = 9; 
int digit4 = 6;
int digit5 = 5; 
int digit6 = 3; 

//Pin mapping from Arduino to the ATmega DIP28 if you need it
//http://www.arduino.cc/en/Hacking/PinMapping
int segA = 0; //Display pin 11
int segB = 1; //Display pin 7
int segC = 2; //Display pin 4
int segD = 4; //Display pin 2
int segE = 7; //Display pin 1
int segF = 8; //Display pin 10
int segG = 12; //Display pin 5
int segDP =13; // Display pin 3



#include < Wire.h >
#include "RTClib.h"
RTC_DS1307 RTC;

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
// original sketck from http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/
// add part with SQW=1Hz from http://tronixstuff.wordpress.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/
// add part with manual adjust http://www.bristolwatch.com/arduino/arduino_ds1307.htm



byte SW0 = A0;
byte SW1 = A2;
byte SW2 = A1;
byte SWT = A3;
int Adhr=0;
int Admnt=0;
int D = 0;
int Z =0;

// use for hexa in zecimal conversion
long zh, uh, ore;
long zm, um, miniti;

void setup() {
  
 //Serial.begin(57600);
  Wire.begin();
  RTC.begin();
 // RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
// if you need set clock... just remove // from line above this

// part code for flashing LED
Wire.beginTransmission(0x68);
Wire.write(0x07); // move pointer to SQW address
// Wire.write(0x00); // turns the SQW pin off
 Wire.write(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave at 1Hz
// Wire.write(0x13); // sends 0x13 (hex) 00010011 (binary) 32kHz

Wire.endTransmission();
  
  
  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);
  pinMode(segDP, OUTPUT);

  pinMode(digit1, OUTPUT);
  pinMode(digit2, OUTPUT);
  pinMode(digit3, OUTPUT);
  pinMode(digit4, OUTPUT);
  pinMode(digit5, OUTPUT);
  pinMode(digit6, OUTPUT);


//Serial.begin(9600);

pinMode(SW0, INPUT);  // N.O. push button switch
pinMode(SW1, INPUT);  // N.O. push button switch
pinMode(SW2, INPUT);  // N.O. push button switch
pinMode(SWT, INPUT);  // N.O. push button switch

digitalWrite(SW0, HIGH); // pull-ups on
digitalWrite(SW1, HIGH);
digitalWrite(SW2, HIGH);
digitalWrite(segDP, LOW);


}


void loop() {

  DateTime now = RTC.now();
  long HR = now.hour()*1000;
  long timp = (HR*10)+now.minute()*100+now.second();
  Adhr = now.hour();
  Admnt=now.minute();

int DIM = 0;

//------------------------------------------------------
//12/24 hours shitching 
//------------------------------------------------------
if (timp < 130000){
digitalWrite(segDP, LOW);}


if (digitalRead(SWT)==0){delay(300);
 if (D == 0) {
 D =1;delay(200);}
 
else{
D =0;}
}

if (D == 0){  
if (timp>=130000)
timp=timp-120000;
}

if ((D == 1)& (timp>=130000) ){ 
digitalWrite(segDP, LOW);}
else
{digitalWrite(segDP, HIGH);
}
//------------------------------------------------------


  



//int timp = (now.minute(), DEC);
//   displayNumber(12); // this is number to diplay


     
    for(int i = 100 ; i >0  ; i--) {
     if (timp >= 100000) displayNumber01(timp); 
     else displayNumber02(timp); 
   } 

   for(int i = 100 ; i >0  ; i--) {
     if (timp >= 100000) displayNumber03(timp); 
     else displayNumber04(timp); 
   } 

   for(int i = 100 ; i >0  ; i--) {
     if (timp >= 100000) displayNumber05(timp); 
     else displayNumber06(timp); 
   } 




  

if (digitalRead(SW0)==0){delay(100);Z=1;  set_time(); }// hold the switch to set time
}





void set_time()   {
  byte minutes1 = 0;
  byte hours1 = 0;
  byte minutes = 0;
  byte hours = 0;
  hours=Adhr;
  minutes=Admnt;

   // zh = hours / 16;
   // uh = hours - 16 * zh ;
   //ore = 10 * zh + uh; 
    //zm = minutes / 16;
    //um = minutes - 16 * zm ;
    //miniti = 10 * zm + um; 

    if ((hours & 0x0f) > 9) hours =  hours + 6;
      //Serial.print(hours & 0x0f);
      //Serial.print(hours);
      if (hours > 0x23) hours = 0;

        if ((minutes & 0x0f) > 9) minutes = minutes + 6;
      //Serial.println(minutes & 0x0f);
     // Serial.println(minutes);
      if (minutes > 0x59) minutes = 0;
      
while (!(Z==0)){ // set time switch must be released to exit


 


    
   int TST = digitalRead(SW2);
    while (TST==0) // set hours
    { 
     hours++;          
     
   // converting hexa in zecimal:
    zh = hours / 16;
    uh = hours - 16 * zh ;
    ore = 10 * zh + uh; 
    zm = minutes / 16;
    um = minutes - 16 * zm ;
    miniti = 10 * zm + um; 
    
     for(int i = 400 ; i >0  ; i--) {
     displayNumber01(ore*10000+miniti*100); 
     }
   
      
      if ((hours & 0x0f) > 9) hours =  hours + 6;
      //Serial.print(hours & 0x0f);
      //Serial.print(hours);
      if (hours > 0x23) hours = 0;
      //Serial.print("Hours = ");
      if (hours <= 9) //Serial.print("0");
      //Serial.println(hours, HEX);
    delay(1);
    TST = digitalRead(SW2);
    }

   while (!(digitalRead(SW1))) // set minutes
    { 
     minutes++;  
   // converting hexa in zecimal:
    zh = hours / 16;
    uh = hours - 16 * zh ;
    ore = 10 * zh + uh; 
    zm = minutes / 16;
    um = minutes - 16 * zm ;
    miniti = 10 * zm + um; 
    
     for(int i = 400 ; i >0  ; i--) {
     displayNumber01(ore*10000+miniti*100); 
     }

      //Serial.println(minutes);
      if ((minutes & 0x0f) > 9) minutes = minutes + 6;
      //Serial.println(minutes & 0x0f);
     // Serial.println(minutes);
      if (minutes > 0x59) minutes = 0;
      //Serial.print("Minutes = ");
      if (minutes >= 9) //Serial.print("0");
      //Serial.println(minutes, HEX);
    delay(1);    
    }

    Wire.beginTransmission(0x68); // activate DS1307
    Wire.write(0); // where to begin
    Wire.write(0x00);          //seconds
    Wire.write(minutes);          //minutes
    Wire.write(0x80 | hours);    //hours (24hr time)
    Wire.write(0x06);  // Day 01-07
    Wire.write(0x01);  // Date 0-31
    Wire.write(0x05);  // month 0-12
    Wire.write(0x09);  // Year 00-99
    Wire.write(0x10); // Control 0x10 produces a 1 HZ square wave on pin 7. 
    Wire.endTransmission();
  
    // converting hexa in zecimal:
    zh = hours / 16;
    uh = hours - 16 * zh ;
    ore = 10 * zh + uh; 
    zm = minutes / 16;
    um = minutes - 16 * zm ;
    miniti = 10 * zm + um; 

 
    
    for(int i = 400 ; i >0  ; i--) {
     displayNumber01(ore*10000+miniti*100); 
     }
delay(100); 
Serial.print(digitalRead(SW0));
if (digitalRead(SW0)==0) Z = 0;
 delay(300);   
  }
//Serial.print(SW2);
}



void displayNumber01(long toDisplay) {
#define DISPLAY_BRIGHTNESS  25

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  for(int digit = 6 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     //digitalWrite(segDP, HIGH);
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      //digitalWrite(segDP, LOW);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 5:
      digitalWrite(digit5, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 6:
      digitalWrite(digit6, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
      
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 


     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);
    digitalWrite(digit6, DIGIT_OFF);
}
} 

void displayNumber02(long toDisplay) {
#define DISPLAY_BRIGHTNESS  25

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  for(int digit = 6 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     lightNumber(10); 
     //digitalWrite(segDP, HIGH);
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      //digitalWrite(segDP, LOW);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
     case 5:
      digitalWrite(digit5, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 6:
      digitalWrite(digit6, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);
    digitalWrite(digit6, DIGIT_OFF);
}
} 

void displayNumber03(long toDisplay) {
#define DISPLAY_BRIGHTNESS  25

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  for(int digit = 6 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     //digitalWrite(segDP, HIGH);
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 5:
      digitalWrite(digit5, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 6:
      digitalWrite(digit6, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);
    digitalWrite(digit6, DIGIT_OFF);
}
} 

void displayNumber04(long toDisplay) {
#define DISPLAY_BRIGHTNESS  25

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  for(int digit = 6 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     lightNumber(10); 
     //digitalWrite(segDP, HIGH);
     break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 5:
      digitalWrite(digit5, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 6:
      digitalWrite(digit6, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);
    digitalWrite(digit6, DIGIT_OFF);
}
} 

void displayNumber05(long toDisplay) {
#define DISPLAY_BRIGHTNESS  25

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  for(int digit = 6 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     digitalWrite(digit1, DIGIT_ON);
     //digitalWrite(segDP, HIGH);
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 5:
      digitalWrite(digit5, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 6:
      digitalWrite(digit6, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);
    digitalWrite(digit6, DIGIT_OFF);
}
} 

void displayNumber06(long toDisplay) {
#define DISPLAY_BRIGHTNESS  25

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  for(int digit = 6 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
     //digitalWrite(digit1, DIGIT_ON);
     //digitalWrite(segDP, HIGH);
      break;
   case 2:
      digitalWrite(digit2, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 5:
      digitalWrite(digit5, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    case 6:
      digitalWrite(digit6, DIGIT_ON);
      //digitalWrite(segDP, HIGH);
      break;
    }
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    delayMicroseconds(DISPLAY_BRIGHTNESS); 

     //Turn off all segments
    lightNumber(10); 

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);
    digitalWrite(digit6, DIGIT_OFF);
}
} 
//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {

#define SEGMENT_ON  HIGH
#define SEGMENT_OFF LOW

  switch (numberToDisplay){

  case 0:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 1:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 2:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 3:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 4:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 5:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 6:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 7:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 8:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 9:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  // all segment are ON
  case 10:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  
  }
// End of the coding, BUDHUSARANAI, Best of luck.
  
}







107 comments:

  1. Code does not compile, there are wrong

    Line==Wire.beginTransmission(0x68); // activate DS1307

    ReplyDelete
  2. please help circuit diagram DS1307 pin connection Atmega328p

    ReplyDelete
    Replies
    1. sorry for my mistake,
      SCL pint to Analog pin 05
      SDA pint to Analog pin 04
      +5 to volt 5
      GND to Ground.
      ignore the other pin

      Delete
    2. This LED use common anode or cathode??

      Delete
  3. Please give me your whatsapp number. I have to discuss to you some doubts with picture

    ReplyDelete
  4. The code is uploded to arduino. But arduino pin13 blinks everytime. Is there a error in code

    ReplyDelete
    Replies
    1. Few people had tried this and worked. There may be some mistakes with your wiring. you can upload your pictures to the following link. https://web.facebook.com/easymadescom

      Delete
  5. If I used common cathode will it work?.if we disconnect RTC pins from Arduino what will happened.I have used Arduino nano and tiny RTC module .I have told you I my previous comment that I uploaded the code to Arduino nano and Arduino pin 13 blinks. Arduino pin12 never gets on.in your diagram pin12 is connected to central segment of led display.is tiny RTC module not comfortable for this project.l have spent a lot of money for this project .so you please respond me fast.

    ReplyDelete
    Replies
    1. If you can use common anode this will be a easy project. Since it is used LEDs it is not a matter to use common anode.
      Yes, even though you have used common cathode you can work with it. But you have to change the codes. Therefore I recommend to use as described in this post common anode.
      RTC module is the memory chip, if you disconnect the wire clock with stop working but it will display some digits. LED on RTC should BLINK once a second. If the IC number is same, tiny RTC module is also work with this. But I can not recommend Arduino mini or Arduino nano for this project.

      Delete
  6. Sir,I think there is a mistake in display circuit.in first picture there are 6 NPN transistors to connect with 7 cathode pins.l think the second transistor circuit is for common anode and the first transistor circuit with led circuit is for common cathode.an I right?

    ReplyDelete
    Replies
    1. Thank you for information , I will check and inform you.

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. I'm can't downlod original code from link above.
    And how wiring dot point?

    ReplyDelete
    Replies
    1. You can use LED on RTC module and link is updated.

      Delete
  10. Is Arduino nano comfortable to this project?.if no why?.

    ReplyDelete
    Replies
    1. I did not have check it yet whether or not support particular libraries with arduino nano.

      Delete
  11. How did you programmed the chip.using FDTI?

    ReplyDelete
    Replies
    1. No, Since arduino uno has inbuilt programming unit you may not need a FDTI. But if you use arduino mini then you may need FDTI.

      Delete
  12. Please add a video that explain the working of RTC switches

    ReplyDelete
  13. No,l meant the time editing switches

    ReplyDelete
    Replies
    1. Editing switchers are used to adjust the time. If you want to adjust the time 1st press “Editing Activator” switch. Then all the LEDs will start to blink. Then you can change HOURs or Minutes by pressing “Hour” and “Minutes” buttons. 12/24 button will change time mode as 24 hours clock or 12hours clock.

      Delete
  14. Common anode means all positive pin of every segment is connected together?

    ReplyDelete
  15. Which did you use in your project,common cathode or common anode?

    ReplyDelete
  16. LED on 7th pin(sqw) of ds1307 RTC is not blinking.now I didn't connect the RTC with Arduino.is the LED only blink after connecting with Arduino?.The led is Everytime on without connecting to Arduino.

    ReplyDelete
  17. Yes.i connected the Battery.But I didn't connect the SDA and SCL pin to Arduino.

    ReplyDelete
  18. Should I program the DS1307 to get 1hz output on SQW pins?

    ReplyDelete
    Replies
    1. No need to program separately. that is why 32Mhx crystal is included.

      Delete
  19. Replies
    1. But remember this, RTC module's battery is only for keeping memory. LED blink only when that circuit is powered 5V to VCC pin.

      Delete
  20. Should I connect the RTC to Arduino when the code is uploading?

    ReplyDelete
    Replies
    1. Yes, then PC time will be uploaded to the RTC module.

      Delete
  21. What will be showing in serial monitor of Arduino ide?

    ReplyDelete
    Replies
    1. I have stopped printing data by "//" on Serial Monitor. If you can see "0" or "1" on serial monitor which means that you have pushed or releases SW0 switch. having removed "//", you can see hours, minutes and seconds accordingly.

      Delete
  22. In my PC the serial monitor running these symbols //()'""[]\

    ReplyDelete
    Replies
    1. If you want to get data from serial monitor find "//Serial.begin(9600);" command and delete "//" marks and upload.

      Delete
  23. In common Anode transistor circuit the Anode of LED is connected to Collector of NPN transistor and Cathode of the LED is connected to Collector of PNP transistor.That means Anode of LED to GND and Cathode of LED to 5v?pls clarify.

    ReplyDelete
    Replies
    1. There is a small correction on LED wiring, I marked it by red colour. Yes you are correct.

      Delete
  24. Hi sir.my project is working.But the brightness of some segment is become very low.what is the reason?

    ReplyDelete
    Replies
    1. use a power supply at least 500mA. It is depend on the type of LEDS. Make sure to use same colour LED and same type of LEDs. Further if you problem not solved, let me know.

      Delete
    2. Hi sir.It was just a problem in my soldering.i solved it and it is now working well.Thank you so much.

      Delete
  25. Time accuracy is low for DS 1307 ic.can replace the fs1307 with ds3231 RTC which is more accurate.

    ReplyDelete
    Replies
    1. My congratulations and if you want to change the accuracy try to change the amount given to the BRIGHTNESS.DS3231 is the one

      Delete
  26. Will ds3231 work with RTClib.h?. when I using ds1307 it loses approximately 4minuts/day.so can I replace ds3231 instead of ds1307?.In many blogs it is showed that ds3231 has a precision of 1ppm.pls clarify.

    ReplyDelete
    Replies
    1. I did not have a issue about 4 minutes error. you have to adjust the code of BRIGHTNESS

      Delete
    2. Sir I solved that problem by changing RTC chip.now it is working well.i also had a problem of automatic changing of 12/24 h format.i also made a solution for this by adding a 10k Resistor b/W Arduino pin A3 and Vcc.

      Delete
    3. Well done. nice to hear new upgrades to this project. keep it up study and practice well.

      Delete
  27. Can i use ds3231 rtc module instead of ds1307 rtc ?

    ReplyDelete
    Replies
    1. yes, you may. but you may have to change the library.

      Delete
  28. Where 15 regulator ics (7805) are uses?
    Please give me complete wiring diagram.

    ReplyDelete
    Replies
    1. No 15 regulator ICs had used. only one is required

      Delete
  29. Does the DP run the colons?

    ReplyDelete
  30. You show the buttons wired to 5v but your code shows they should be grounded and pulled high in software.

    ReplyDelete
    Replies
    1. Got it working but in the 12hr mode the first digit is a zero. I want it blank like yours. What part of your code does this.

      Delete
    2. Edit this part

      for(int i = 100 ; i >0 ; i--) {
      if (timp >= 100000) displayNumber01(timp);
      else displayNumber02(timp);
      }

      for(int i = 100 ; i >0 ; i--) {
      if (timp >= 100000) displayNumber03(timp);
      else displayNumber04(timp);
      }

      for(int i = 100 ; i >0 ; i--) {
      if (timp >= 100000) displayNumber05(timp);
      else displayNumber06(timp);
      }

      Delete
  31. Not yet, still building. But was just asking are the buttons grounded or tied to 5v. it seems the schematic contradicts the code.

    ReplyDelete
  32. Arduino digital pin output current is 40ma max.. But you use 4 led in series it consumes 80ma

    ReplyDelete
    Replies
    1. That is why I have given the power to LED by Transistors.

      Delete
  33. Good work bro thanks for sharing your experience good luck

    ReplyDelete
  34. Brother, I try it on Proteus, but it not work...plz help ,,how to do this....please please please.

    ReplyDelete
    Replies
    1. 1st check LED wiring. Give separate power to LED and check that all the LEDs are working and polarity is correct. Not working mean? I need more information.

      Delete
  35. Brother, i upload a pic on facebook, please see this,,i am try common anode & common Cathode but its not working properly..

    link= (https://www.facebook.com/photo.php?fbid=1731130863608067&set=p.1731130863608067&type=3&theater)

    ReplyDelete
    Replies
    1. Where is the 3V battery to power the RTC module?

      Delete
  36. have you built the project or it is just simulation?

    ReplyDelete
  37. Hello
    How to connect AM/PM LED? There is no way on the diagram

    ReplyDelete
    Replies
    1. ConnEct an LED through 220ohm resiator to pin 13.

      Delete
  38. Can i change NPN transistor as 2N2222 ?

    ReplyDelete
  39. Hello
    Mama hadapu clock eke 11 pin eken signal enne neha. digit 1 eka on wenne ne. aneth digit 5ma blink wenawa.

    ReplyDelete
    Replies
    1. Wiring check karanna. samaharawita 11 pin eka dead wela ethi. ehema welanam IC eka change karanna wei.

      Delete
  40. All led blank. Time not show

    ReplyDelete
  41. WHEN I UPLOAD CODE, ALL DIGIT SHOW 8 NUMBER WITH BLINKING & TIME IS NOT SHOWING
    SO WHATS FALT HERE

    ReplyDelete
    Replies
    1. check wirings again and the transisters types, it should be correctly NPN and PNP

      Delete
  42. i'm using seven segment display with direct connect to atmega328, not using transistor
    so why this not showing number

    ReplyDelete
    Replies
    1. Because the transistors change the anode and cathode, If you use SSD directly, you have to change some codes. And also it is depend on the common polarity of SSD.

      Delete
  43. yes you are right bro, finaly its work
    i changed it polarity in code, HIGH TO LOW & LOW TO HIGH
    THANKS BRO YOU ARE GOOD ENGINEER

    ReplyDelete
  44. There is one more thing bro that setting switches not work
    pushbutton connected to vcc 5v with 1k resistance
    what to do now

    ReplyDelete
    Replies
    1. The you have to troubleshoot it. 1st add code under void setup as Serial.begin(9600);

      then next to the button code: Eg if it is SW0 button add a code as Serial.print("SW0 : ");
      Serial.println(digilalRead(SW0));

      Then run serial monitor and press SW0 switch. and check the readings. you have to repeat same thing if you want to check all the other switchers as well. Then you can find out switchers are working or not. if the reading is always same, there is an issue in wiring. *** When serial print is working, your clock will be mad. do not worry. If you can not upload the codes, just disconnect pin 0 and pin 1 from SSD.

      Delete
    2. Some times that issue had come. therefore I changed the switches wiring diagram. Check the updates.

      Delete
  45. when i connect switches to ground instead of vcc 5v then its working well

    ReplyDelete
  46. becouse i used digital pins 2,3,4,5 not analog input pins,

    ReplyDelete
  47. Please Anura, I am still building this project but am using the common cathode , please tell me what I need to change in the code or hardware for the project to work like the common anode. I will be expecting your reply soon. Thank you :-)

    ReplyDelete
  48. If you change the transistors as i shown in this post above, you no need to change the codes.

    ReplyDelete
  49. If i change RTC DS3231, what code part have to change?

    ReplyDelete
    Replies
    1. you have to change the library
      https://github.com/rodan/ds3231

      Delete
  50. I changed library but here have error like this

    ledclks:115: error: 'RTC' was not declared in this scope

    DateTime now = RTC.now();

    ReplyDelete

-->
Copyright © 2013 Easy Mades