Created
July 12, 2017 07:25
-
-
Save JarekParal/574509a456b565cf7ce49f7a208770ab to your computer and use it in GitHub Desktop.
Clock - example 2 - with alarm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "LearningKit.h" | |
int hour, min, sec; | |
bool alarm = false; | |
void setup() { | |
Serial.begin(115200); | |
setupLeds(); | |
setupRgbLed(); | |
setupButtons(); | |
hour = 17; | |
min = 29; | |
sec = 50; | |
} | |
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; | |
} | |
if(digitalRead(SW1) == false) { | |
alarm = false; | |
} | |
if((hour == 17) && (min == 30) && (sec == 0)) { | |
alarm = true; | |
} | |
if(alarm == true) { | |
digitalWrite(L_R, HIGH); | |
} else { | |
digitalWrite(L_R, LOW); | |
} | |
Serial.printf("%2i:%02i:%02i\n", hour, min, sec); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment