Trivial little program blinks the time on D7

Hello.

Here is a trivial little program to make the Photon blink the time in hours and minutes. You can set your own timezone. Cheers!

////////////////////////////////////////////////////////////////////////////////////////////////////
///// Blink-Clock by Grace B Thomson 3/3/2019
///// This little program just blinks the time in Hours and Minutes
////////////////////////////////////////////////////////////////////////////////////////////////////

int led = D7;                       // The onboard LED
int h, m, i;

void setup() {
    pinMode(led, OUTPUT);
    Time.zone(-8);                   // Set Timezone to Pacific time.
}

void loop() {
    h = Time.hour();                // Get the time
    m = Time.minute();
    
    for(i = 0; i < h; i++){         // Blink the hours
      digitalWrite(led, LOW);
      delay(400);                   //  Slower bkink rate
      digitalWrite(led, HIGH);
      delay(400);
      digitalWrite(led, LOW);
      }
      
    delay(800);                     // Blink the minutes
    for(i = 0; i < m; i++){
      digitalWrite(led, LOW);
      delay(200);                   // Faster blink rate
      digitalWrite(led, HIGH);
      delay(200);
      digitalWrite(led, LOW);
      }
      
    delay(8000);                    // Pause before next update
}

///////////////////////////////////////////////////////////////////
// -eof-

Regards.

73
-Grace
NNNN
z

2 Likes