Skip to content

Instantly share code, notes, and snippets.

@vicatcu
Created October 31, 2013 16:32
Show Gist options
  • Save vicatcu/7252771 to your computer and use it in GitHub Desktop.
Save vicatcu/7252771 to your computer and use it in GitHub Desktop.
displayTime function using 4 day chained counters
#include <DayCounter.h>
#include <ShiftRegister.h>
/* * * * * * * * * * * * * * * * * *
* pin 5 = DayCounter.SER (data) *
* pin 7 = DayCounter.CLK (clock) *
* pin 9 = DayCounter.RCK (latch) *
* * * * * * * * * * * * * * * * * */
DayCounter dc(5, 7, 9);
int count = 0;
void setup()
{
/* nothing to do here */
}
void loop()
{
for(int day = 0; day < 100; day++)
for(int hour = 0; hour < 24; hour++)
for(int minute = 0; minute < 60; minute++)
for(int second = 0; second < 60; second++){
displayTime(day, hour, minute, second);
delay(200); // some time to watch the display change
}
}
void displayTime(int days, int hours, int minutes, int seconds){
uint32_t number = 0;
number += seconds;
number += minutes * 100;
number += hours * 10000;
number += days * 1000000;
dc.displayNumber(number, 8, -1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment