Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Last active May 14, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryanhu1015/e8cbd026a7157c6b213676fcd692cc2f to your computer and use it in GitHub Desktop.
Save Ryanhu1015/e8cbd026a7157c6b213676fcd692cc2f to your computer and use it in GitHub Desktop.
master
/*skip those varible which i initailized*/
void loop()
{
timeTracing();
}
void transmit(byte addr, byte something)
{
Wire.beginTransmission(addr);
Wire.write(something);
Wire.endTransmission();
}
void timeTracing(void)
{
timeNow = millis() / 1000;
seconds = timeNow - timeLast;
digits = seconds % 10;
transmit(0x09, digits);//transmit the number which is just one byte each time
ten_digits = seconds / 10;
transmit(0x08, ten_digits);
if (seconds == 60)
{
timeLast = timeNow;
minutes = minutes + 1;
mins = minutes;
}
if (minutes == 60)
{
minutes = 0;
mins = minutes;
hours = hours + 1;
hrs = hours;
}
mins_digits = mins % 10;
transmit(0x07, mins_digits);
mins_ten_digits = mins / 10;
transmit(0x06, mins_ten_digits);
if (hours == 24) {
hours = 0;
hrs = hours;
days = days + 1;
}
hrs_digits = hrs % 10;
transmit(0x05, hrs_digits);
hrs_ten_digits = hrs / 10;
transmit(0x04, hrs_ten_digits);
/*
there are still something below...skip!
.
.
.
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment