First Commit

This commit is contained in:
MindCreeper03
2025-02-27 19:31:50 +01:00
parent bcbb6aff9a
commit e490df1715
2470 changed files with 1479965 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
/*
getAXTimeTest.ino
Jacob Nuernberg
08/22
Testing getAXTimeMethods.
Code should generate the following output every 5s on the Serial Monitor:
-> Initialize AlarmBits: 0
-> getA1Time(): 1110
-> getA2Time(): 1111110
-> getA1Time(): 1110
-> getA2Time(): 1110000
Tested on:
- Arduino nano
*/
#include <DS3231.h>
#include <Wire.h>
// Setup clock
DS3231 myRTC;
void setup() {
// Begin I2C communication
Wire.begin();
// Begin Serial communication
Serial.begin(57600);
// Setup alarm one to fire every minute
// No need to turn Alarm one on.
myRTC.turnOffAlarm(1);
myRTC.setA1Time(0, 0, 0, 0, 0b01111110, false, false, false);
myRTC.checkIfAlarm(1);
// Setup alarm two to fire every minute
// No need to turn Alarm two on.
myRTC.turnOffAlarm(2);
myRTC.setA2Time(0, 0, 0, 0b01111110, false, false, false);
myRTC.checkIfAlarm(2);
}
void loop() {
// Initialize AlarmBits
byte AlarmBits = 0x0;
Serial.print("Initialize AlarmBits: ");
Serial.println(AlarmBits, BIN);
// Initialize Others
byte ADay, AHour, AMinute, ASecond;
bool ADy, Ah12, APM;
// getA1Time (not clearing).
// Expected AlarmBits = 0x(0000)1110
myRTC.getA1Time(ADay, AHour, AMinute, ASecond, AlarmBits, ADy, Ah12, APM);
Serial.print("getA1Time(): ");
Serial.println(AlarmBits, BIN);
// getA2Time (not clearing).
// Expected AlarmBits = 0x01111110
myRTC.getA2Time(ADay, AHour, AMinute, AlarmBits, ADy, Ah12, APM);
Serial.print("getA2Time(): ");
Serial.println(AlarmBits, BIN);
// getA1Time (clearing).
// Expected AlarmBits = 0x(0000)1110
myRTC.getA1Time(ADay, AHour, AMinute, ASecond, AlarmBits, ADy, Ah12, APM, true);
Serial.print("getA1Time(): ");
Serial.println(AlarmBits, BIN);
// getA2Time (clearing).
// Expected AlarmBits = 0x01110000
myRTC.getA2Time(ADay, AHour, AMinute, AlarmBits, ADy, Ah12, APM, true);
Serial.print("getA2Time(): ");
Serial.println(AlarmBits, BIN);
delay(5000);
}