Advertisement
SallatielFernandes

RTC-alarme-delay

Jul 1st, 2022
767
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Wire.h>
  2. #include <DS3231.h>
  3. #define GND 2
  4. #define POSITIVO 5
  5.  
  6.  
  7. RTClib myRTC;
  8.  
  9. void setup () {
  10.   pinMode(GND, OUTPUT);
  11.   pinMode(POSITIVO, OUTPUT);
  12.  
  13.   digitalWrite(GND, LOW);
  14.   digitalWrite(POSITIVO, LOW);
  15.  
  16.     Serial.begin(57600);
  17.     Wire.begin();
  18. }
  19.  
  20. void loop () {
  21.    
  22.     delay(1000);
  23.    
  24.     DateTime now = myRTC.now();
  25.    
  26.     Serial.print(now.year(), DEC);
  27.     Serial.print('/');
  28.     Serial.print(now.month(), DEC);
  29.     Serial.print('/');
  30.     Serial.print(now.day(), DEC);
  31.     Serial.print(' ');
  32.     Serial.print(now.hour(), DEC);
  33.     Serial.print(':');
  34.     Serial.print(now.minute(), DEC);
  35.     Serial.print(':');
  36.     Serial.print(now.second(), DEC);
  37.     Serial.println();
  38.  
  39.     if(now.hour()==14 && now.minute()==53 && now.second()==00){
  40.       digitalWrite(POSITIVO, HIGH);
  41.       delay(1000);
  42.       digitalWrite(POSITIVO, LOW);
  43.     }
  44. }
Advertisement
RAW Paste Data Copied
Advertisement