Want to make a digital clock with Arduino Uno & 7 segment Led Display

Hi,

I have just began with arduino and have a RTC module, a few 8x8 dot matrix led module interfaced with MAX 7219, Multiplexed 7 segment led display's. I want to make a digital clock. I have gone through a lot of sketches, but i don't know "how to display the time to the 7 segment led display module or to the 8x8 dot matrix led module interfaced with MAX 7219"

This will be very kind, if someone helps me with a detailed schematic & a working program.

Thanks in advance :)

(deleted)

Start here, particularly the bit about DO NOT CROSS-POST.

Well, i tried to understand the libraries and functions by looking on different sketches, but could not understand anything. So i am actually looking for a schematic and a working sketch.

Well, i tried to understand the libraries and functions by looking on different sketches, but could not understand anything

So, start with some of the example sketches supplied with the IDE. Work through the examples, play around with them.

I have just began with arduino and have a RTC module, a few 8x8 dot matrix led module interfaced with MAX 7219, Multiplexed 7 segment led display's. I want to make a digital clock. I have gone through a lot of sketches, but i don't know "how to display the time to the 7 segment led display module or to the 8x8 dot matrix led module interfaced with MAX 7219"

Well, i tried to understand the libraries and functions by looking on different sketches, but could not understand anything. So i am actually looking for a schematic and a working sketch.

Yes , well that's a shame, however, this is not a program writing service or a schematic drawing service. This is a help forum. We are more that happy to point you to tutorials or help you debug your code or proof read your schematic, but we are not going to write the code for you nor are we going to draw the schematic. That is your responsibility. If this is a homework assignment then I suggest you start with Google. You need to get the RTC module working to the point that it prints out the time to the serial monitor. I have an RTC and it didn't take very long to get it working. First you have to give us a Situation Report on what you have done so far toward getting the RTC and 7-segment display working. We can't help you if we don't know what progress you have made.

Check the Parola library, makes writing things to MAX7219/display easy.
Wiring up a MAX7219/8x8 matrix is pretty straightforward.
(ignore the 2nd Max7219 here)

CrossRoads came up with this clock sketch that I modified for 24-hour.
It uses Serial Monitor, but it should be easy enough to knock out the numbers as segments, etc. using shift registers or a 7219 routine instead.

/*  
    CrossRoads Timeclock  
    Adapted for 24hr time
    by Me!  08SEPT2012
    __h__m__s
    and leading zeros, too
*/

unsigned long previousTime = 0;
byte seconds ;
byte minutes ;
byte hours ;

void setup()
{
  //  Preset HHMMSS for 24hr rollover test
  //  Could jump to a function to set time
  //  and start
  seconds = 45;
  minutes =  59;
  hours =  23;
  Serial.begin (9600);
}

void loop ()
{
// I wonder whether "microseconds"...
  if (millis() >= (previousTime)) 
  {
     previousTime = previousTime + 1000;  // use 100000 for uS
     seconds = seconds +1;
     if (seconds == 60)
     {
        seconds = 0;
        minutes = minutes +1;
     }
     if (minutes == 60)
     {
        minutes = 0;
        hours = hours +1;
     }
     if (hours == 24)
     {
       hours = 0;
     }
     if (hours < 10)
     {
       Serial.print("0");
     }
     Serial.print (hours, DEC);
     Serial.print ("h");
     if (minutes < 10)
     {
       Serial.print("0");
     }
     Serial.print (minutes,DEC);
     Serial.print ("m");
     if (seconds < 10)
     {
       Serial.print("0");
     }
     Serial.print(seconds,DEC);
     Serial.println("s");
  } // end 1 second
} // end loop

You might even say that it’s deceptively accurate.

Hello All,

I too am working on a qty 2 by 4x7 segment display common cathode with DS1302RTC and TMP36 temp sensor input. I am using the MAX7219 for the multiplexing and have been successful in passing the temp reading to 4 of the 8 digits but all the RTC libraries I find rely on serial transfer for the RTC data to most often an LCD display, not a 7 segment and especially not via a MAX7129.

I have a reasonable code below that hopefully someone can make sense of. As I only have 4 digits left I only want to display the HH.MM data on the 7 seg. I have modified examples found about to serial.print the MIN and HOURS and am attempting to catch the data from the serial feed by using ‘serial.available’ and ‘Time=serial.parseInt();’ and then loading Time into a function which is almost the same as the function used to send the temp to the display (which works).

I can see the min and hour data on the serial monitor 002319000023190000231900002319…But i cant manage to grab it and use it for my function. Its driving me nuts. I just get “00.00” on the display.
I’m using the “LedControl.h” and <DS1302.h> libraries.

If someone could please take a look at my code especially void loop and please offer ideas on how to get the data off the serial and use it for my function I would appreciate it!

Thanks Jason.

#include "LedControl.h" //  need the library
#include <DS1302.h>

LedControl lc=LedControl(12,11,10,1); // lc is our object
// pin 12 is connected to the MAX7219 pin 1
// pin 11 is connected to the CLK pin 13
// pin 10 is connected to LOAD pin 12
// 1 as we are only using 1 MAX7219

DS1302 rtc(2, 3, 4);// Init the DS1302
// I assume you know how to connect the DS1302.
// DS1302:  CE pin    -> Arduino Digital 2
//          I/O pin   -> Arduino Digital 3
//          SCLK pin  -> Arduino Digital 4

int tempPin=A5;
float sample;
float tempC;
float tempF;
int TIME;

// Init a Time-data structure
Time t;

void setup()
{
  pinMode(tempPin,INPUT);
  lc.shutdown(0,false);// turn off power saving, enables display
  lc.setIntensity(0,10);// sets brightness (0~15 possible values)
  lc.clearDisplay(0);// clear screen
  
  // Set the clock to run-mode, and disable the write protection
  rtc.halt(false);
  rtc.writeProtect(false);
  
  // Setup Serial connection
  Serial.begin(9600);

  // The following lines can be commented out to use the values already stored in the DS1302
  rtc.setTime(23,19,44);     // Set the time to 12:00:00 (24hr format)
}

void printNumber(float num)
{
  int ones;
  int tens;
  int hundreds;
  int v=(int)num;
  float diff=num-v;
  diff=diff*100;
  int fones,ftens;
  fones=(int)diff%10;
  diff=diff/10;
  ftens=(int)diff%10;
  diff=diff/10;
  ones=v%10;
  v=v/10;
  tens=v%10;
  v=v/10;
  hundreds=v;  
  //Now print the number digit by digit
 // lc.setDigit(0,4,(byte)hundreds,false);
  lc.setDigit(0,3,(byte)tens,false);
  lc.setDigit(0,2,(byte)ones,true);
  lc.setDigit(0,1,(byte)ftens,false);
  //lc.setDigit(0,0,(byte)fones,false);
  lc.setChar(0,0,'c',false);
}

void printTime(float num)
{
  int ones;
  int tens;
  int hundreds;
  int thou;
  int tenthou;
  
  int v=(int)num;
  float diff=num-v;
  diff=diff*100;
  int fones,ftens;
  fones=(int)diff%10;
  diff=diff/10;
  ftens=(int)diff%10;
  diff=diff/10;
  
  ones=v%10;      ///12345 ==> 1234.5 so 5 is remainder
  v=v/10;         ///12545/10 ==> 1234 int
  tens=v%10;      ///1234 ==> 123.4 so 4 is remainder
  v=v/10;         ///1234/10 ==> 123 int
  hundreds=v%10;  ///123 ==> 12.3 so 3 is remainder
  v=v/10;         ///123/10 ==> 12 int
  thou=v%10;      ///12 ==> 1.2 so 2 is remainter
  v=v/10;         ///12/10 ==> 1 int
  tenthou=v%10;   ///1 ==> 0.1 so 1 is remainder
  
  //Now print the number digit by digit
  lc.setDigit(0,7,(byte)thou,false);
  lc.setDigit(0,6,(byte)hundreds,false);
  lc.setDigit(0,5,(byte)tens,false);
  lc.setDigit(0,4,(byte)ones,false);
}

void loop()
{
  sample=0; 
  for(int i=0;i<150;i++)
  {
    sample+=analogRead(tempPin);  //read the value from the sensor
    delay(2);
  }
  {
    sample=sample/150; 
    tempC=(sample*100.0)/1023.0;   //convert the analog data to temperature  
    printNumber(tempC);
  }
  ///////////////////////////////////
  while(1)
  {
    // Get data from the DS1302
    t = rtc.getTime();
    Serial.print(t.hour, DEC);
    Serial.print(t.min, DEC); 
    
    while (Serial.available() > 0) 
    {
    TIME = Serial.parseInt();
    }
    
    printTime((float)TIME);
    delay(1000);
  }
  delay(1000);
}