Skip to content

Instantly share code, notes, and snippets.

@JarekParal
Created July 12, 2017 07:25
Show Gist options
  • Select an option

  • Save JarekParal/72ee0de0f50bacdbfdffd1a9d1407d01 to your computer and use it in GitHub Desktop.

Select an option

Save JarekParal/72ee0de0f50bacdbfdffd1a9d1407d01 to your computer and use it in GitHub Desktop.

Revisions

  1. JarekParal created this gist Jul 12, 2017.
    44 changes: 44 additions & 0 deletions clock-1.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #include "LearningKit.h"

    int hour, min, sec;

    void setup() {
    Serial.begin(115200);
    setupLeds();
    setupRgbLed();

    hour = 17;
    min = 29;
    sec = 0;
    }

    void loop() {
    sec = sec + 1;
    delay(1000);
    if(sec == 60) {
    //min = min + 1;
    min += 1;
    sec = 0;
    }
    if(min == 60) {
    //hour = hour + 1;
    hour++;
    min = 0;
    }
    if(hour == 24) {
    hour = 0;
    }

    // Serial.print(hour);
    // Serial.print(":");
    // Serial.print(min);
    // Serial.print(":");
    // Serial.println(sec);
    Serial.printf("%2i:%02i:%02i\n", hour, min, sec);

    if((hour == 17) && (min == 30)) {
    digitalWrite(L_R, HIGH);
    } else {
    digitalWrite(L_R, LOW);
    }
    }