Help with time increments for a LED clock display

Hey Everyone,

I’ve been working on a personal project for myself lately, and I have run into sort of a writers block in Arduino. I finished the hardware part, which I am more experienced in than the coding part. It’s a basic clock, where after a minute has passed the display increases by one minute and so on. I intend to start the clock at 3 P.M and allow the clock to increase its time after that. The display gives me enough space to only display hours and minutes. I have found a method to display the numbers, but I would like to know how to set up a method that will increase the amount of minutes after a minute passes, same thing with hours. Sorry for the vague explanation, as I do not know how to explain my situation very well. Here is my code so far below:

const int SIN = 10;     
const int CLK = 9;   
const int LAT = 4;   
const int BLK = 13;  
const int EN = 7;    
const int OnOff = A0;  
const int switchOne = A1;
const int switchTwo = A2;  
const int ENBAT = 11;               
const word numbers[10] = { 0xAEAE, 0x2A00, 0x9C9C, 0xBC94, 0x3830, 0xB4B4, 0xB4BC, 0x2C80, 0xBCBC, 0xBCB4 };






void setup () {
  pinMode(ENBAT, OUTPUT);
  digitalWrite(ENBAT, HIGH);
  pinMode(SIN, OUTPUT);    
  pinMode(CLK, OUTPUT);
  pinMode(LAT, OUTPUT);
  pinMode(BLK, OUTPUT);
  pinMode(EN,OUTPUT);
  digitalWrite(EN,HIGH);
  digitalWrite(BLK, HIGH); 

  pinMode(OnOff,INPUT);
  digitalWrite(OnOff, HIGH);

  pinMode(switchOne, INPUT);
  digitalWrite(switchOne, HIGH);

  pinMode(switchTwo, INPUT);
  digitalWrite(switchTwo, HIGH);
  
  for(int i = 0; i < 9; i++) {
  digitalWrite(LAT, LOW);
  shiftOut(SIN, CLK, MSBFIRST, 0x00);
  digitalWrite(LAT, HIGH);
  }
    
  analogWrite(BLK, 127); // dimming

  
  
  
}

void loop () {
                           
         
    word number = numbers[0];
    
    digitalWrite(LAT, LOW);
    shiftOut(SIN, CLK, MSBFIRST, (number >> 8 ));  
    shiftOut(SIN, CLK, MSBFIRST, number);   
     number = numbers[0];  
    shiftOut(SIN, CLK, MSBFIRST, (number >> 8 ));  
    shiftOut(SIN, CLK, MSBFIRST, number);
      number = numbers[0];  
    shiftOut(SIN, CLK, MSBFIRST, (number >> 8 ));  
    shiftOut(SIN, CLK, MSBFIRST, number);
     number = numbers[0];  
    shiftOut(SIN, CLK, MSBFIRST, (number >> 8 ));  
    shiftOut(SIN, CLK, MSBFIRST, number);
    digitalWrite(LAT, HIGH);
    delay(500);
    
    
  
  
}

Clock_Display_Code.ino (1.65 KB)

What kind of display are You talking about?
Code is preferably attached within code brackets, </>.

It's a 4 digit 16 segment alphanumeric 1 inch LED display by Embedded Adventures.

Minutes 58, 59, 60 would turn to 1 hour 0 minutes. Then minutes counts up until 60, hours are stepped up by one, seconds set to 0...
What is it You want to show on the display? Attach the entire code in the proper way.

Put the code in the brackets, I'm new to the forum, sorry. Anyway, I want to display the current time, The Pacific Time Zone.

Take a short dive into this : Introductory Tutorials - Arduino Forum

I’m not that experienced in arduino, and I would like to know how to display the current time on a 4 digit 16 segment alphanumeric 1 inch LED display. My code is below. I am only able to change the numbers on the screen through shiftOut. I want my display to become a functioning clock. Anything helps!

const int SIN = 10;     
const int CLK = 9;   
const int LAT = 4;   
const int BLK = 13;  
const int EN = 7;    
const int OnOff = A0;  
const int switchOne = A1;
const int switchTwo = A2;  
const int ENBAT = 11;               
const word numbers[10] = { 0xAEAE, 0x2A00, 0x9C9C, 0xBC94, 0x3830, 0xB4B4, 0xB4BC, 0x2C80, 0xBCBC, 0xBCB4 };






void setup () {
  pinMode(ENBAT, OUTPUT);
  digitalWrite(ENBAT, HIGH);
  pinMode(SIN, OUTPUT);    
  pinMode(CLK, OUTPUT);
  pinMode(LAT, OUTPUT);
  pinMode(BLK, OUTPUT);
  pinMode(EN,OUTPUT);
  digitalWrite(EN,HIGH);
  digitalWrite(BLK, HIGH); 

  pinMode(OnOff,INPUT);
  digitalWrite(OnOff, HIGH);

  pinMode(switchOne, INPUT);
  digitalWrite(switchOne, HIGH);

  pinMode(switchTwo, INPUT);
  digitalWrite(switchTwo, HIGH);
  
  for(int i = 0; i < 9; i++) {
  digitalWrite(LAT, LOW);
  shiftOut(SIN, CLK, MSBFIRST, 0x00);
  digitalWrite(LAT, HIGH);
  }
    
  analogWrite(BLK, 127); // dimming

  
  
  
}

void loop () {
                           
         
    word number = numbers[0];
    
    digitalWrite(LAT, LOW);
    shiftOut(SIN, CLK, MSBFIRST, (number >> 8 ));  
    shiftOut(SIN, CLK, MSBFIRST, number);   
     number = numbers[0];  
    shiftOut(SIN, CLK, MSBFIRST, (number >> 8 ));  
    shiftOut(SIN, CLK, MSBFIRST, number);
      number = numbers[0];  
    shiftOut(SIN, CLK, MSBFIRST, (number >> 8 ));  
    shiftOut(SIN, CLK, MSBFIRST, number);
     number = numbers[0];  
    shiftOut(SIN, CLK, MSBFIRST, (number >> 8 ));  
    shiftOut(SIN, CLK, MSBFIRST, number);
    digitalWrite(LAT, HIGH);
    delay(500);
    
    
  
  
}

Try here

My code is below

Oh no it's not !

This thread continues the thread of "Help with time increments for a LED clock display".
Cross posting, waisting our time.
I'm out.

You can try something like this:

const int SIN = 10;     
const int CLK = 9;   
const int LAT = 4;   
const int BLK = 13; 
const int EN = 7;   
const int OnOff = A0; 
const int switchOne = A1;
const int switchTwo = A2; 
const int ENBAT = 11;               
const unsigned int numbers[10] = 
{ 
        0xAEAE, 
        0x2A00, 
        0x9C9C, 
        0xBC94, 
        0x3830, 
        0xB4B4, 
        0xB4BC, 
        0x2C80, 
        0xBCBC, 
        0xBCB4 
        
    };


void setup () 
{
    pinMode(ENBAT, OUTPUT);
    digitalWrite(ENBAT, HIGH);
    pinMode(SIN, OUTPUT);   
    pinMode(CLK, OUTPUT);
    pinMode(LAT, OUTPUT);
    pinMode(BLK, OUTPUT);
    pinMode(EN,OUTPUT);
    digitalWrite(EN,HIGH);
    digitalWrite(BLK, HIGH);

    pinMode(OnOff,INPUT);
    digitalWrite(OnOff, HIGH);

    pinMode(switchOne, INPUT);
    digitalWrite(switchOne, HIGH);

    pinMode(switchTwo, INPUT);
    digitalWrite(switchTwo, HIGH);
 
    for(int i = 0; i < 9; i++) 
    {
        digitalWrite(LAT, LOW);
        shiftOut(SIN, CLK, MSBFIRST, 0x00);
        digitalWrite(LAT, HIGH);
    }
   
    analogWrite(BLK, 127); // dimming
    
}//setup

void loop () 
{   
    static unsigned long
        timeSecond = 0;
    unsigned long
        timeNow;      
    static byte
        hours = 3,        
        minutes = 0,
        lastMinutes = 59,        
        seconds = 0;
        
    timeNow = millis();
    if( timeNow - timeSecond >= 1000ul )
    {
        timeSecond = timeNow;
        seconds++;
        if( seconds == 60 )
        {
            seconds = 0;
            minutes++;
            if( minutes == 60 )
            {
                minutes = 0;
                hours++;
                if( hours > 12 )
                    hours = 1;
            }//if
            
        }//if
        
    }//if

    if( minutes != lastMinutes )
    {
        lastMinutes = minutes;
        byte dig1 = hours/10;
        byte dig2 = hours%10;
        byte dig3 = minutes/10;
        byte dig4 = minutes%10;

        //may need to adjust order these are sent
        digitalWrite(LAT, LOW);
        shiftOut(SIN, CLK, MSBFIRST, (numbers[dig1] >> 8 )); 
        shiftOut(SIN, CLK, MSBFIRST, (numbers[dig1] & 0xff));   
        shiftOut(SIN, CLK, MSBFIRST, (numbers[dig2] >> 8 )); 
        shiftOut(SIN, CLK, MSBFIRST, (numbers[dig2] & 0xff));   
        shiftOut(SIN, CLK, MSBFIRST, (numbers[dig3] >> 8 )); 
        shiftOut(SIN, CLK, MSBFIRST, (numbers[dig3] & 0xff));   
        shiftOut(SIN, CLK, MSBFIRST, (numbers[dig4] >> 8 )); 
        shiftOut(SIN, CLK, MSBFIRST, (numbers[dig4] & 0xff));           
        digitalWrite(LAT, HIGH);                
        
    }//if
        
}//loop

Thank you so much! I appreciate the help and the time you put in to help me :slight_smile:

@UninformedPancake

Do NOT CROSS post.
TOPICS MERGED

Please READ THIS for future reference.

Bob.