• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 1 głosów - średnia: 5
  • 1
  • 2
  • 3
  • 4
  • 5
Zegar RTC PCF8563 lub inne zasilanie z baterii. Czy są takie dostępne?
#11
Przyszedł zegar podłaczyłem i jestem miło zaskoczony działa fajnie, dokładnie nie spr spania ale tak na szybko miernik pokazał 2.5uA zegar razem z prockiem.
Tylko nie wiem jak ustawić dwa alarmy  Confused
Gdy ustawiam jeden przerwanie budzi procek o danej godz, ale jak powielam linijkę set.alarm to z dwóch jedna się wykonuje. Macie jakiś pomysł?

Kod:
#include <Wire.h>
#include <Rtc_Pcf8563.h>

/* get a real time clock object */
Rtc_Pcf8563 rtc;
/* a flag for the interrupt */
volatile int alarm_flag=0;

/* the interrupt service routine */
void blink()
{
  alarm_flag=1;
}

void setup()
{


  Serial.begin(9600);

  /* clear out all the registers */
  rtc.initClock();
  /* set a time to start with.
  * day, weekday, month, century, year */
  rtc.setDate(14, 6, 3, 0, 10);
  /* hr, min, sec */
  rtc.setTime(1, 15, 40);
  /* set an alarm for 20 secs later...
  * alarm pin goes low when match occurs
  * this triggers the interrupt routine
  * min, hr, day, weekday
  * 99 = no alarm value to be set
  */
  rtc.setAlarm(16, 99, 99, 99);
rtc.setAlarm(16, 99, 99, 99);  // dla drugiego alarmu

  /* setup int on pin 3 of arduino */
  attachInterrupt(1, blink, FALLING);
  alarm_flag=0;
}

void loop()
{
  /* each sec update the display */
  Serial.print(rtc.formatTime());
  Serial.print("  ");
  Serial.print(rtc.formatDate());
  Serial.print("  0x");
  Serial.print(rtc.getStatus2(), HEX);
  Serial.print("\r\n");
  delay(1000);
  if (alarm_flag==1){
    clr_alarm();
  }

}

void clr_alarm()
{
  rtc.clearAlarm();
  delay(1000);
  alarm_flag=0;

}
 
Odpowiedź
  


Wiadomości w tym wątku
RE: Zegar RTC PCF8563 lub inne zasilanie z baterii. Czy są takie dostępne? - przez brendy - 18-10-2022, 17:12

Skocz do:


Przeglądający: 3 gości