Advertisement
SallatielFernandes

RTC-now-alarme-10seg

Jul 1st, 2022
892
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.56 KB | None
  1. #include <Wire.h>
  2. #include <DS3231.h>
  3. #define GND 2
  4. #define POSITIVO 5
  5.  
  6. RTClib myRTC;
  7.  
  8. void setup () {
  9.   pinMode(GND, OUTPUT);
  10.   pinMode(POSITIVO, OUTPUT);
  11.  
  12.   digitalWrite(GND, LOW);
  13.   digitalWrite(POSITIVO, LOW);
  14.  
  15.   Wire.begin();
  16. }
  17.  
  18. void loop () {
  19.  
  20.     DateTime now = myRTC.now();
  21.    
  22.     // Alarma do segundo "0" ao segundo "9" (10 segundos)
  23.     if(now.hour()==15 && now.minute()==05 && now.second()>=0 && now.second()<10){
  24.       digitalWrite(POSITIVO, HIGH);
  25.       delay(200);
  26.       digitalWrite(POSITIVO, LOW);
  27.       delay(200);
  28.     }
  29. }
Advertisement
RAW Paste Data Copied
Advertisement