[SOLVED] DS3231 Alarm Mode - Loop Through Options & Determine Current Status

I'm trying to sequence through the alarm settings for a DS3231 RTC.

I'm using an LCD with a keypad and using the buttons to set the RTC.

I can set all other details but I can't seem to get the alarm mode to set.

I'm new to Bytes and so I could be making a glaring error there.

I've tried to just set the A1 alarm or both the alarms, it doesn't seem to make a difference.

I used the code from ArduinoChicken/alarmControl.ino at master · mlepard/ArduinoChicken · GitHub to set the alarm mode.

I'm using the DS3231 library DS3231 - Arduino Reference

Any help would be appreciated.

/*
DS3231_Alarm_Setting_Trial.pde
Guy Lowndes
2020-12-18

Information taken from DS3231_set and DS3231_test by Eric Ayars 4/11

Uses an LCD with keypad to set the time for a DS3231 RTC

uses code for the buttons from https://forum.arduino.cc/index.php?topic=354260.0 by Mark Bramwell, July 2010

Uses tips and tricks from https://www.baldengineer.com/arduino-lcd-display-tips.html

*/

#include <DS3231.h>
#include <Wire.h>
#include <LiquidCrystal.h>

DS3231 Clock;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

/*****************************************************************************************************************/

// These are the ALARM Bits that can be used
// They need to be combined into a single value (see below)
// Found here: https://github.com/mlepard/ArduinoChicken/blob/master/roboCoop/alarmControl.ino
#define ALRM1_MATCH_EVERY_SEC     0b1111  // once a second
#define ALRM1_MATCH_SEC           0b1110  // when seconds match
#define ALRM1_MATCH_MIN_SEC       0b1100  // when minutes and seconds match
#define ALRM1_MATCH_HR_MIN_SEC    0b1000  // when hours, minutes, and seconds match
#define ALRM1_MATCH_DY_HR_MIN_SEC 0b0000  // when hours, minutes, and seconds match

#define ALRM2_ONCE_PER_MIN     0b111   // once per minute (00 seconds of every minute)
#define ALRM2_MATCH_MIN        0b110   // when minutes match
#define ALRM2_MATCH_HR_MIN     0b100   // when hours and minutes match

/*****************************************************************************************************************/

// buffers for the display
char line0[21]; 
char line1[21];

// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;
const int btnRIGHT = 0;
const int btnUP     =1;
const int btnDOWN   =2;
const int btnLEFT   =3;
const int btnSELECT =4;
const int btnNONE   =5;
int bounceDelay;
int oldKey = 0;


/***************************************************************
 * Set up and Loop
 ***************************************************************/

void setup() {
  // Start the serial port
  Serial.begin(9600);
  Serial.println("Starting");

  // Start the I2C interface
  Wire.begin();
  
}

void loop() {

  for (int i = 1; i<6; i++)
  {
       changeAlarmMethod1(true);
       delay(2000);
  }
  
}

void changeAlarmMethod1(bool increase) {

  byte ALRM1_SET;
  byte ALRM2_SET;
  byte alarmBits;
  String myString2="";

  byte ADay1, AHour1, AMinute1, ASecond1, ABits1;
  byte ADay2, AHour2, AMinute2, ABits2;

  bool ADy1, A12h1, Apm1;
  bool ADy2, A12h2, Apm2;

  Clock.getA2Time(ADay1, AHour1, AMinute1, ABits2, ADy2, A12h2, Apm2);
  ALRM2_SET=ABits2 >> 4;
  Serial.print("A2 Current = ");
  Serial.print(ALRM2_SET, BIN);
  Serial.print("  ");
   
  Clock.getA1Time(ADay1, AHour1, AMinute1, ASecond1, ABits1, ADy1, A12h1, Apm1);
  ALRM1_SET=ABits1 & 0x0F;  
  Serial.print("A1 Current = ");
  Serial.println(ALRM1_SET, BIN);

  switch (ALRM1_SET){
    case ALRM1_MATCH_EVERY_SEC: // once a second
    {
      Serial.println("ALRM1_MATCH_EVERY_SEC");
      if (increase) {ALRM1_SET=ALRM1_MATCH_SEC;}      
      else {ALRM1_SET=ALRM1_MATCH_DY_HR_MIN_SEC;}
      break;
    }
    case ALRM1_MATCH_SEC:       // when seconds match
    {
      Serial.println("ALRM1_MATCH_SEC");
      if (increase) {ALRM1_SET=ALRM1_MATCH_MIN_SEC;}
      else {ALRM1_SET=ALRM1_MATCH_EVERY_SEC;}
      break;
    }
    case ALRM1_MATCH_MIN_SEC:   // when minutes and seconds match
    {
      Serial.println("ALRM1_MATCH_MIN_SEC");
      if (increase) {ALRM1_SET=ALRM1_MATCH_HR_MIN_SEC;}
      else {ALRM1_SET=ALRM1_MATCH_SEC;}
      break;
    }
    case ALRM1_MATCH_HR_MIN_SEC:
    {
      Serial.println("ALRM1_MATCH_HR_MIN_SEC");
      if (increase) {ALRM1_SET=ALRM1_MATCH_DY_HR_MIN_SEC;}
      else {ALRM1_SET=ALRM1_MATCH_MIN_SEC;}
      break;
    }
    case ALRM1_MATCH_DY_HR_MIN_SEC:
    {
      Serial.println("ALRM1_MATCH_DY_HR_MIN_SEC");
      if (increase) {ALRM1_SET=ALRM1_MATCH_EVERY_SEC;}
      else {ALRM1_SET=ALRM1_MATCH_HR_MIN_SEC;}
      break;
    }
  }

  byte newAlarmBits = ALRM2_SET;
  newAlarmBits <<= 4;
  newAlarmBits |= ALRM1_SET;

  Clock.setA1Time(ADay1, AHour1, AMinute1, ASecond1, newAlarmBits, false, A12h1, Apm1);
  Clock.setA2Time(ADay2, AHour2, AMinute2, newAlarmBits, false, A12h2, Apm2);
  Serial.print("New alarm bits= ");
  Serial.println(newAlarmBits, BIN);
  

  Clock.getA2Time(ADay1, AHour1, AMinute1, ABits2, ADy2, A12h2, Apm2);
  ALRM2_SET=ABits2 >> 4;
  Serial.print("A2 New = ");
  Serial.print(ALRM2_SET, BIN);
  Serial.print("  ");

  Serial.print("ABits2 New = ");
  Serial.println(ABits2, BIN);
  
   
  Clock.getA1Time(ADay1, AHour1, AMinute1, ASecond1, ABits1, ADy1, A12h1, Apm1);
  ALRM1_SET=ABits1 & 0x0F;  
  Serial.print("A1 New = ");
  Serial.println(ALRM2_SET, BIN);

  Serial.print("ABits1 New = ");
  Serial.println(ABits1, BIN);
  
}

I managed to get a loop working but I don't know why

/*
DS3231_Alarm_Setting_Trial.pde
Guy Lowndes
2020-12-18

Information taken from DS3231_set and DS3231_test by Eric Ayars 4/11

Uses an LCD with keypad to set the time for a DS3231 RTC

uses code for the buttons from https://forum.arduino.cc/index.php?topic=354260.0 by Mark Bramwell, July 2010

Uses tips and tricks from https://www.baldengineer.com/arduino-lcd-display-tips.html

*/

#include <DS3231.h>
#include <Wire.h>
#include <LiquidCrystal.h>

DS3231 Clock;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

/*****************************************************************************************************************/

// These are the ALARM Bits that can be used
// They need to be combined into a single value (see below)
// Found here: https://github.com/mlepard/ArduinoChicken/blob/master/roboCoop/alarmControl.ino
#define ALRM1_MATCH_EVERY_SEC     0b1111  // once a second
#define ALRM1_MATCH_SEC           0b1110  // when seconds match
#define ALRM1_MATCH_MIN_SEC       0b1100  // when minutes and seconds match
#define ALRM1_MATCH_HR_MIN_SEC    0b1000  // when hours, minutes, and seconds match
#define ALRM1_MATCH_DY_HR_MIN_SEC 0b0000  // when hours, minutes, and seconds match

#define ALRM2_ONCE_PER_MIN     0b111   // once per minute (00 seconds of every minute)
#define ALRM2_MATCH_MIN        0b110   // when minutes match
#define ALRM2_MATCH_HR_MIN     0b100   // when hours and minutes match

/*****************************************************************************************************************/

// buffers for the display
char line0[21]; 
char line1[21];

// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;
const int btnRIGHT = 0;
const int btnUP     =1;
const int btnDOWN   =2;
const int btnLEFT   =3;
const int btnSELECT =4;
const int btnNONE   =5;
int bounceDelay;
int oldKey = 0;


/***************************************************************
 * Set up and Loop
 ***************************************************************/

void setup() {
  // Start the serial port
  Serial.begin(9600);
  Serial.println("Starting");

  // Start the I2C interface
  Wire.begin();

  Serial.print("ALRM1_MATCH_EVERY_SEC = ");
  Serial.println(ALRM1_MATCH_EVERY_SEC, BIN);

  Serial.print("ALRM1_MATCH_SEC = ");
  Serial.println(ALRM1_MATCH_SEC, BIN);

  Serial.print("ALRM1_MATCH_MIN_SEC = ");
  Serial.println(ALRM1_MATCH_MIN_SEC, BIN);

  Serial.print("ALRM1_MATCH_HR_MIN_SEC = ");
  Serial.println(ALRM1_MATCH_HR_MIN_SEC, BIN);

  Serial.print("ALRM1_MATCH_DY_HR_MIN_SEC = ");
  Serial.println(ALRM1_MATCH_DY_HR_MIN_SEC, BIN);

  Serial.print("ALRM2_ONCE_PER_MIN = ");
  Serial.println(ALRM2_ONCE_PER_MIN, BIN);

  Serial.print("ALRM2_MATCH_MIN = ");
  Serial.println(ALRM2_MATCH_MIN, BIN);

  Serial.print("ALRM2_MATCH_HR_MIN = ");
  Serial.println(ALRM2_MATCH_HR_MIN, BIN);

}

void loop() {

  for (int i = 1; i<6; i++)
  {
       changeAlarmMethod1(true, i);
       delay(5000);
  }
  
}

void changeAlarmMethod1(bool increase, int i) {

  byte ALRM1_SET;
  byte ALRM2_SET;
  byte alarmBits;

  byte ADay1, AHour1, AMinute1, ASecond1, ABits1;
  byte ADay2, AHour2, AMinute2, ABits2;

  bool ADy1, A12h1, Apm1;
  bool ADy2, A12h2, Apm2;
  
  Clock.getA2Time(ADay1, AHour1, AMinute1, ABits2, ADy2, A12h2, Apm2);
  Clock.getA1Time(ADay1, AHour1, AMinute1, ASecond1, ABits1, ADy1, A12h1, Apm1);

  Serial.print("ABits1 = ");
  Serial.print(ABits1, BIN);
  Serial.print("  ");
  Serial.print("ABits2 = ");
  Serial.print(ABits2, BIN);
  Serial.println("  ");

  byte newAlarmBits;

  if ((ABits2>>4)==ALRM2_MATCH_HR_MIN) {newAlarmBits = ALRM2_ONCE_PER_MIN;}
  else if ((ABits2>>4)==ALRM2_ONCE_PER_MIN) {newAlarmBits = ALRM2_MATCH_MIN;}
  else {newAlarmBits = ALRM2_MATCH_HR_MIN;}

  Serial.print("New Alarm Bits After Alarm2= ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");
  
  newAlarmBits <<= 4;  
  
  if (ABits1==ALRM1_MATCH_DY_HR_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_EVERY_SEC;}
  else if (ABits1==ALRM1_MATCH_EVERY_SEC) {newAlarmBits |= ALRM1_MATCH_SEC;}
  else if (ABits1==ALRM1_MATCH_SEC) {newAlarmBits |= ALRM1_MATCH_MIN_SEC;}
  else if (ABits1==ALRM1_MATCH_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
  else {newAlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}

  ALRM1_SET = ABits1 & B00001111;
  Serial.print("ALRM1_Set = ");
  Serial.print(ALRM1_SET, BIN);
  Serial.println("  ");

  Clock.setA1Time(ADay1, AHour1, AMinute1, ASecond1, newAlarmBits, false, A12h1, Apm1);
  Clock.setA2Time(ADay2, AHour2, AMinute2, newAlarmBits, false, A12h2, Apm2);

  Serial.print("New Alarm Bits = ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

}

Thanks for using code tags on your first post! However, you haven't described the problem. "I can't seem to get the alarm mode to set" does not help us.

Please explain why you think alarm mode is not set.

People on this forum often recommend the Jack Christensen DS3231 library.

I thought I'd fixed it but not quite.

When I use a two condition if statement, where alarnNum=1 and fwd=true

void changeAlarmMethod(int alarmNum, bool fwd) {
  byte ALRM1_SET;
  byte ALRM2_SET;
  byte alarmBits;

  byte ADay1, AHour1, AMinute1, ASecond1, ABits1;
  byte ADay2, AHour2, AMinute2, ABits2;

  bool ADy1, A12h1, Apm1;
  bool ADy2, A12h2, Apm2;
  
  Clock.getA2Time(ADay1, AHour1, AMinute1, ABits2, ADy2, A12h2, Apm2);
  Clock.getA1Time(ADay1, AHour1, AMinute1, ASecond1, ABits1, ADy1, A12h1, Apm1);

  Serial.print("ABits1 = ");
  Serial.print(ABits1, BIN);
  Serial.print("  ");
  Serial.print("ABits2 = ");
  Serial.print(ABits2, BIN);
  Serial.println("  ");

  byte newAlarmBits;

  if (alarmNum==2) {
    if ((ABits2>>4)==ALRM2_MATCH_HR_MIN) {newAlarmBits = ALRM2_ONCE_PER_MIN;}
    else if ((ABits2>>4)==ALRM2_ONCE_PER_MIN) {newAlarmBits = ALRM2_MATCH_MIN;}
    else {newAlarmBits = ALRM2_MATCH_HR_MIN;}
  }
  else {
    newAlarmBits=(ABits2>>4);
  }
  

  Serial.print("New Alarm Bits After Alarm2= ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

  newAlarmBits <<= 4;  

  Serial.print("New Alarm Bits After Alarm2 Shifted= ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

  ABits1  = ABits1 & B00001111;

  if (alarmNum==1 && bool(fwd)) {
      if (ABits1==ALRM1_MATCH_EVERY_SEC) {newAlarmBits |= ALRM1_MATCH_SEC;}
      else if (ABits1==ALRM1_MATCH_SEC) {newAlarmBits |= ALRM1_MATCH_MIN_SEC;}
      else if (ABits1==ALRM1_MATCH_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
      else if (ABits1==ALRM1_MATCH_HR_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}
      else {newAlarmBits |= ALRM1_MATCH_EVERY_SEC;}
  }
  
  Serial.print("New Alarm Bits After Alarm1= ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

  Clock.setA1Time(ADay1, AHour1, AMinute1, ASecond1, newAlarmBits, ADy1, A12h1, Apm1);
  Clock.setA2Time(ADay2, AHour2, AMinute2, newAlarmBits, ADy2, A12h2, Apm2);

  Serial.print("New Alarm Bits = ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

}

This is the print out

21:32:18.398 -> Starting
21:32:29.718 -> ABits1 = 1111 ABits2 = 1100000
21:32:29.765 -> New Alarm Bits After Alarm2= 110
21:32:29.811 -> New Alarm Bits After Alarm2 Shifted= 1100000
21:32:29.858 -> New Alarm Bits After Alarm1= 1101110
21:32:29.904 -> New Alarm Bits = 1101110
21:32:35.005 -> ABits1 = 1111 ABits2 = 1100000
21:32:35.005 -> New Alarm Bits After Alarm2= 110
21:32:35.098 -> New Alarm Bits After Alarm2 Shifted= 1100000
21:32:35.145 -> New Alarm Bits After Alarm1= 1101110
21:32:35.145 -> New Alarm Bits = 1101110
21:32:39.117 -> ABits1 = 1111 ABits2 = 1100000
21:32:39.209 -> New Alarm Bits After Alarm2= 110
21:32:39.209 -> New Alarm Bits After Alarm2 Shifted= 1100000
21:32:39.255 -> New Alarm Bits After Alarm1= 1101110
21:32:39.302 -> New Alarm Bits = 1101110

It is calculating the new alarm mask but the RTC isn't updating.

However, if I simply change the fwd condition to true:

void changeAlarmMethod(int alarmNum, bool fwd) {
  byte ALRM1_SET;
  byte ALRM2_SET;
  byte alarmBits;

  byte ADay1, AHour1, AMinute1, ASecond1, ABits1;
  byte ADay2, AHour2, AMinute2, ABits2;

  bool ADy1, A12h1, Apm1;
  bool ADy2, A12h2, Apm2;
  
  Clock.getA2Time(ADay1, AHour1, AMinute1, ABits2, ADy2, A12h2, Apm2);
  Clock.getA1Time(ADay1, AHour1, AMinute1, ASecond1, ABits1, ADy1, A12h1, Apm1);

  Serial.print("ABits1 = ");
  Serial.print(ABits1, BIN);
  Serial.print("  ");
  Serial.print("ABits2 = ");
  Serial.print(ABits2, BIN);
  Serial.println("  ");

  byte newAlarmBits;

  if (alarmNum==2) {
    if ((ABits2>>4)==ALRM2_MATCH_HR_MIN) {newAlarmBits = ALRM2_ONCE_PER_MIN;}
    else if ((ABits2>>4)==ALRM2_ONCE_PER_MIN) {newAlarmBits = ALRM2_MATCH_MIN;}
    else {newAlarmBits = ALRM2_MATCH_HR_MIN;}
  }
  else {
    newAlarmBits=(ABits2>>4);
  }
  

  Serial.print("New Alarm Bits After Alarm2= ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

  newAlarmBits <<= 4;  

  Serial.print("New Alarm Bits After Alarm2 Shifted= ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

  ABits1  = ABits1 & B00001111;

  if (alarmNum==1 && true) {
      if (ABits1==ALRM1_MATCH_EVERY_SEC) {newAlarmBits |= ALRM1_MATCH_SEC;}
      else if (ABits1==ALRM1_MATCH_SEC) {newAlarmBits |= ALRM1_MATCH_MIN_SEC;}
      else if (ABits1==ALRM1_MATCH_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
      else if (ABits1==ALRM1_MATCH_HR_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}
      else {newAlarmBits |= ALRM1_MATCH_EVERY_SEC;}
  }
  
  Serial.print("New Alarm Bits After Alarm1= ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

  Clock.setA1Time(ADay1, AHour1, AMinute1, ASecond1, newAlarmBits, ADy1, A12h1, Apm1);
  Clock.setA2Time(ADay2, AHour2, AMinute2, newAlarmBits, ADy2, A12h2, Apm2);

  Serial.print("New Alarm Bits = ");
  Serial.print(newAlarmBits, BIN);
  Serial.println("  ");

}

The RTC alarm mode changes:

21:37:31.378 -> Starting
21:37:43.830 -> ABits1 = 1110 ABits2 = 1100111
21:37:43.875 -> New Alarm Bits After Alarm2= 110
21:37:43.922 -> New Alarm Bits After Alarm2 Shifted= 1100000
21:37:43.968 -> New Alarm Bits After Alarm1= 1101100
21:37:43.968 -> New Alarm Bits = 1101100
21:37:45.138 -> ABits1 = 1100 ABits2 = 1100111
21:37:45.185 -> New Alarm Bits After Alarm2= 110
21:37:45.231 -> New Alarm Bits After Alarm2 Shifted= 1100000
21:37:45.278 -> New Alarm Bits After Alarm1= 1101000
21:37:45.324 -> New Alarm Bits = 1101000
21:37:48.186 -> ABits1 = 1000 ABits2 = 1100111
21:37:48.186 -> New Alarm Bits After Alarm2= 110
21:37:48.232 -> New Alarm Bits After Alarm2 Shifted= 1100000
21:37:48.327 -> New Alarm Bits After Alarm1= 1100000
21:37:48.327 -> New Alarm Bits = 1100000

I can't understand why this would happen

Every time time I think I'm getting there I don't

The alarm just isn't updating properly or consistently, maybe I'm going around in circles.

I've simplified the code:

#include <DS3231.h>
#include <Wire.h>

DS3231 Clock;

/*****************************************************************************************************************/

// These are the ALARM Bits that can be used
// They need to be combined into a single value (see below)
// Found here: https://github.com/mlepard/ArduinoChicken/blob/master/roboCoop/alarmControl.ino
#define ALRM1_MATCH_EVERY_SEC     0b1111  // once a second
#define ALRM1_MATCH_SEC           0b1110  // when seconds match
#define ALRM1_MATCH_MIN_SEC       0b1100  // when minutes and seconds match
#define ALRM1_MATCH_HR_MIN_SEC    0b1000  // when hours, minutes, and seconds match
#define ALRM1_MATCH_DY_HR_MIN_SEC 0b0000  // when hours, minutes, and seconds match

#define ALRM2_ONCE_PER_MIN     0b111   // once per minute (00 seconds of every minute)
#define ALRM2_MATCH_MIN        0b110   // when minutes match
#define ALRM2_MATCH_HR_MIN     0b100   // when hours and minutes match

/*****************************************************************************************************************/
// variables to collect the information from the RTC
byte Year;
byte Month;
byte Date;
byte DoW;
byte Hour;
byte Minute;
byte Second;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;

With the function:

void changeAlarmMethod(int alarmNum, int dir) {

  byte newAlarmBits;
  
  if (alarmNum==1){
    Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);  

    ABits  = ABits & 0b1111;

    Serial.print("ALRM1_MATCH_EVERY_SEC = ");
    Serial.println(ALRM1_MATCH_EVERY_SEC, BIN);

    Serial.print("ALRM1_MATCH_SEC = ");
    Serial.println(ALRM1_MATCH_SEC, BIN);

    Serial.print("ALRM1_MATCH_MIN_SEC = ");
    Serial.println(ALRM1_MATCH_MIN_SEC, BIN);

    Serial.print("ALRM1_MATCH_HR_MIN_SEC = ");
    Serial.println(ALRM1_MATCH_HR_MIN_SEC, BIN);
    
    Serial.print("Initial ABits=");
    Serial.println(ABits, BIN);
    
    if (dir == 1) {
        if (ABits==ALRM1_MATCH_EVERY_SEC) {newAlarmBits |= ALRM1_MATCH_SEC;}        
        else if (ABits==ALRM1_MATCH_SEC) {newAlarmBits |= ALRM1_MATCH_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_HR_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}
        else {newAlarmBits |= ALRM1_MATCH_EVERY_SEC;}
    }
    else if (dir == 0) {
        if (ABits==ALRM1_MATCH_EVERY_SEC) {newAlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_SEC) {newAlarmBits |= ALRM1_MATCH_EVERY_SEC;}
        else if (ABits==ALRM1_MATCH_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_SEC;}
        else if (ABits==ALRM1_MATCH_HR_MIN_SEC) {newAlarmBits |= ALRM1_MATCH_MIN_SEC;}
        else {newAlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
    }
    else {newAlarmBits |= ABits;}

    Serial.print("New Alarm Bits=");
    Serial.println(newAlarmBits, BIN);

    Serial.println("Match the coding in the DS32313 Library");

    Serial.print("A1M1 <<7=");
    Serial.println((newAlarmBits & 0b00000001) << 7 , BIN);

    Serial.print("A1M2 <<6=");
    Serial.println((newAlarmBits & 0b00000010) << 6 , BIN);

    Serial.print("A1M3 <<5=");
    Serial.println((newAlarmBits & 0b00000100) << 5 , BIN);

    Serial.print("A1M4 <<4=");
    Serial.println((newAlarmBits & 0b00001000) << 4 , BIN);
    
    Clock.setA1Time(ADay, AHour, AMinute, ASecond, newAlarmBits, ADy, A12h, Apm);
    Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);  

    Serial.print("Revised ABits=");
    Serial.println(ABits, BIN);    
    
  } else {
    Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);  
   
    if (dir == 1) {
      if ((ABits>>4)==ALRM2_ONCE_PER_MIN) {newAlarmBits = ALRM2_MATCH_MIN;}
      else if ((ABits>>4)==ALRM2_MATCH_MIN) {newAlarmBits = ALRM2_MATCH_HR_MIN;}
      else {newAlarmBits = ALRM2_ONCE_PER_MIN;}
    }
    if (dir == 0) {
      if ((ABits>>4)==ALRM2_ONCE_PER_MIN) {newAlarmBits = ALRM2_MATCH_HR_MIN;}
      else if ((ABits>>4)==ALRM2_MATCH_HR_MIN) {newAlarmBits = ALRM2_MATCH_MIN;}
      else {newAlarmBits = ALRM2_ONCE_PER_MIN;}
    }
    else {
      newAlarmBits=(ABits>>4);
    }
    
    Clock.setA2Time(ADay, AHour, AMinute, newAlarmBits, ADy, A12h, Apm);
  }
  
  
}

If I set alarmNum=1 and dir=1 I get the following result after three passes

14:21:08.246 -> ALRM1_MATCH_EVERY_SEC = 1111
14:21:08.246 -> ALRM1_MATCH_SEC = 1110
14:21:08.293 -> ALRM1_MATCH_MIN_SEC = 1100
14:21:08.293 -> ALRM1_MATCH_HR_MIN_SEC = 1000
14:21:08.338 -> Initial ABits=1110
14:21:08.386 -> New Alarm Bits=1100
14:21:08.386 -> Match the coding in the DS32313 Library
14:21:08.433 -> A1M1 <<7=0
14:21:08.433 -> A1M2 <<6=0
14:21:08.481 -> A1M3 <<5=10000000
14:21:08.481 -> A1M4 <<4=10000000
14:21:08.481 -> Revised ABits=1110
14:21:23.075 -> ALRM1_MATCH_EVERY_SEC = 1111
14:21:23.122 -> ALRM1_MATCH_SEC = 1110
14:21:23.122 -> ALRM1_MATCH_MIN_SEC = 1100
14:21:23.168 -> ALRM1_MATCH_HR_MIN_SEC = 1000
14:21:23.214 -> Initial ABits=1110
14:21:23.214 -> New Alarm Bits=1100
14:21:23.261 -> Match the coding in the DS32313 Library
14:21:23.307 -> A1M1 <<7=0
14:21:23.307 -> A1M2 <<6=0
14:21:23.307 -> A1M3 <<5=10000000
14:21:23.353 -> A1M4 <<4=10000000
14:21:23.353 -> Revised ABits=1110
14:21:24.901 -> ALRM1_MATCH_EVERY_SEC = 1111
14:21:24.947 -> ALRM1_MATCH_SEC = 1110
14:21:24.947 -> ALRM1_MATCH_MIN_SEC = 1100
14:21:24.994 -> ALRM1_MATCH_HR_MIN_SEC = 1000
14:21:25.040 -> Initial ABits=1110
14:21:25.040 -> New Alarm Bits=1100
14:21:25.087 -> Match the coding in the DS32313 Library
14:21:25.133 -> A1M1 <<7=0
14:21:25.133 -> A1M2 <<6=0
14:21:25.133 -> A1M3 <<5=10000000
14:21:25.133 -> A1M4 <<4=10000000
14:21:25.179 -> Revised ABits=1110

The section "Matching the coding in the DS3231 Library" refers to my attempts to see if the value being submitted was valid.

The function in the Library is:

void DS3231::setA1Time(byte A1Day, byte A1Hour, byte A1Minute, byte A1Second, byte AlarmBits, bool A1Dy, bool A1h12, bool A1PM) {
  //  Sets the alarm-1 date and time on the DS3231, using A1* information
  byte temp_buffer;
  Wire.beginTransmission(CLOCK_ADDRESS);
  Wire.write(0x07); // A1 starts at 07h
  // Send A1 second and A1M1
  Wire.write(decToBcd(A1Second) | ((AlarmBits & 0b00000001) << 7));
  // Send A1 Minute and A1M2
  Wire.write(decToBcd(A1Minute) | ((AlarmBits & 0b00000010) << 6));
  // Figure out A1 hour 
  if (A1h12) {
    // Start by converting existing time to h12 if it was given in 24h.
    if (A1Hour > 12) {
      // well, then, this obviously isn't a h12 time, is it?
      A1Hour = A1Hour - 12;
      A1PM = true;
    }
    if (A1PM) {
      // Afternoon
      // Convert the hour to BCD and add appropriate flags.
      temp_buffer = decToBcd(A1Hour) | 0b01100000;
    } else {
      // Morning
      // Convert the hour to BCD and add appropriate flags.
      temp_buffer = decToBcd(A1Hour) | 0b01000000;
    }
  } else {
    // Now for 24h
    temp_buffer = decToBcd(A1Hour); 
  }
  temp_buffer = temp_buffer | ((AlarmBits & 0b00000100)<<5);
  // A1 hour is figured out, send it
  Wire.write(temp_buffer); 
  // Figure out A1 day/date and A1M4
  temp_buffer = ((AlarmBits & 0b00001000)<<4) | decToBcd(A1Day);
  if (A1Dy) {
    // Set A1 Day/Date flag (Otherwise it's zero)
    temp_buffer = temp_buffer | 0b01000000;
  }
  Wire.write(temp_buffer);
  // All done!
  Wire.endTransmission();
}

So I discovered I don't need to update Alarm 2 at the same time as Alarm 1 but I'm struggling with the rest of the process.

I'm hoping this is now getting somewhere.

I've rewritten the function

void changeAlarmMethod(int alarmNum, int dir) {

  byte ADay, AHour, AMinute, ASecond, ABits;
  bool ADy, A12h, Apm;


  Clock.turnOffAlarm(1);
  Clock.turnOffAlarm(2);

  byte newAlarmBits;
  
  if (alarmNum==1){
    Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);  

    ABits  = ABits & 0b1111;

    Serial.print("ALRM1_MATCH_EVERY_SEC = ");
    Serial.println(ALRM1_MATCH_EVERY_SEC, BIN);

    Serial.print("ALRM1_MATCH_SEC = ");
    Serial.println(ALRM1_MATCH_SEC, BIN);

    Serial.print("ALRM1_MATCH_MIN_SEC = ");
    Serial.println(ALRM1_MATCH_MIN_SEC, BIN);

    Serial.print("ALRM1_MATCH_HR_MIN_SEC = ");
    Serial.println(ALRM1_MATCH_HR_MIN_SEC, BIN);
    
    Serial.print("Initial ABits=");
    Serial.println(ABits, BIN);

    int AlarmBits;
    AlarmBits = ALRM2_ONCE_PER_MIN;
    AlarmBits <<= 4;

    Serial.print("Initial AlarmBits=");
    Serial.println(AlarmBits, BIN);

    Serial.print("Match ALRM1_MATCH_EVERY_SEC ");
    Serial.println((ABits==ALRM1_MATCH_EVERY_SEC));

    Serial.print("Match ALRM1_MATCH_SEC ");
    Serial.println((ABits==ALRM1_MATCH_SEC));

    Serial.print("Match ALRM1_MATCH_MIN_SEC ");
    Serial.println((ABits==ALRM1_MATCH_MIN_SEC));

    Serial.print("Match ALRM1_MATCH_HR_MIN_SEC ");
    Serial.println((ABits==ALRM1_MATCH_HR_MIN_SEC));

    Serial.print("Match ALRM1_MATCH_DY_HR_MIN_SEC ");
    Serial.println((ABits==ALRM1_MATCH_DY_HR_MIN_SEC));

    if (dir == 1) {
        if (ABits==ALRM1_MATCH_EVERY_SEC) {AlarmBits |= ALRM1_MATCH_SEC;}        
        else if (ABits==ALRM1_MATCH_SEC) {AlarmBits |= ALRM1_MATCH_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_MIN_SEC) {AlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_DY_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_EVERY_SEC;}
        }
    else if (dir == 0) {
        if (ABits==ALRM1_MATCH_EVERY_SEC) {AlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_SEC) {AlarmBits |= ALRM1_MATCH_EVERY_SEC;}
        else if (ABits==ALRM1_MATCH_MIN_SEC) {AlarmBits |= ALRM1_MATCH_SEC;}
        else if (ABits==ALRM1_MATCH_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_MIN_SEC;}
        else {AlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
    }
    else {AlarmBits |= ABits;}

    Serial.print("New Alarm Bits=");
    Serial.println(AlarmBits, BIN);

    Serial.println("Match the coding in the DS32313 Library");

    Serial.print("A1M1 <<7=");
    Serial.println((AlarmBits & 0b00000001) << 7 , BIN);

    Serial.print("A1M2 <<6=");
    Serial.println((AlarmBits & 0b00000010) << 6 , BIN);

    Serial.print("A1M3 <<5=");
    Serial.println((AlarmBits & 0b00000100) << 5 , BIN);

    Serial.print("A1M4 <<4=");
    Serial.println((AlarmBits & 0b00001000) << 4 , BIN);

    Serial.print("ADay=");
    Serial.println(ADay , BIN);

    
    Clock.setA1Time(ADay, AHour, AMinute, ASecond, AlarmBits, ADy, A12h, Apm);
    Clock.setA2Time(ADay, AHour, AMinute, AlarmBits, ADy, A12h, Apm);

    Clock.turnOnAlarm(1);
    Clock.turnOnAlarm(2);

    Clock.turnOffAlarm(1);
    Clock.turnOffAlarm(2);
    byte newBits;
    Clock.getA1Time(ADay, AHour, AMinute, ASecond, newBits, ADy, A12h, Apm);  

    Clock.turnOnAlarm(1);
    Clock.turnOnAlarm(2);

    Serial.print("New Bits=");
    Serial.println(newBits, BIN);    
    
  } else {
    Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);  
   
    if (dir == 1) {
      if ((ABits>>4)==ALRM2_ONCE_PER_MIN) {newAlarmBits = ALRM2_MATCH_MIN;}
      else if ((ABits>>4)==ALRM2_MATCH_MIN) {newAlarmBits = ALRM2_MATCH_HR_MIN;}
      else {newAlarmBits = ALRM2_ONCE_PER_MIN;}
    }
    if (dir == 0) {
      if ((ABits>>4)==ALRM2_ONCE_PER_MIN) {newAlarmBits = ALRM2_MATCH_HR_MIN;}
      else if ((ABits>>4)==ALRM2_MATCH_HR_MIN) {newAlarmBits = ALRM2_MATCH_MIN;}
      else {newAlarmBits = ALRM2_ONCE_PER_MIN;}
    }
    else {
      newAlarmBits=(ABits>>4);
    }
    
    Clock.setA2Time(ADay, AHour, AMinute, newAlarmBits, ADy, A12h, Apm);
  }
  
  
}

And what I started to think was that overwriting the same variables wasn't working and was sending me duff results through the serial print. The serial print from this function now starts to suggest everything is fine.

I've also added a number of commands to switch the alarms on and off, I read somewhere that the data is written to the alarms when they are switched on (not too sure about this). I'm now going to start commenting out areas to see what really matters and what doesn't.

So now the changing of the alarm mode works for alarm1

void changeAlarmMethod(int alarmNum, int dir) {

  byte ADay, AHour, AMinute, ASecond, ABits;
  bool ADy, A12h, Apm;

  int AlarmBits;
  
  if (alarmNum==1){
    Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);  

    ABits  = ABits & 0b1111;

    Serial.print("ALRM1_MATCH_EVERY_SEC = ");
    Serial.println(ALRM1_MATCH_EVERY_SEC, BIN);

    Serial.print("ALRM1_MATCH_SEC = ");
    Serial.println(ALRM1_MATCH_SEC, BIN);

    Serial.print("ALRM1_MATCH_MIN_SEC = ");
    Serial.println(ALRM1_MATCH_MIN_SEC, BIN);

    Serial.print("ALRM1_MATCH_HR_MIN_SEC = ");
    Serial.println(ALRM1_MATCH_HR_MIN_SEC, BIN);
    
    Serial.print("Initial ABits=");
    Serial.println(ABits, BIN);

    Serial.print("Initial AlarmBits=");
    Serial.println(AlarmBits, BIN);

    Serial.print("Match ALRM1_MATCH_EVERY_SEC ");
    Serial.println((ABits==ALRM1_MATCH_EVERY_SEC));

    Serial.print("Match ALRM1_MATCH_SEC ");
    Serial.println((ABits==ALRM1_MATCH_SEC));

    Serial.print("Match ALRM1_MATCH_MIN_SEC ");
    Serial.println((ABits==ALRM1_MATCH_MIN_SEC));

    Serial.print("Match ALRM1_MATCH_HR_MIN_SEC ");
    Serial.println((ABits==ALRM1_MATCH_HR_MIN_SEC));

    Serial.print("Match ALRM1_MATCH_DY_HR_MIN_SEC ");
    Serial.println((ABits==ALRM1_MATCH_DY_HR_MIN_SEC));

    if (dir == 1) {
        if (ABits==ALRM1_MATCH_EVERY_SEC) {AlarmBits |= ALRM1_MATCH_SEC;}        
        else if (ABits==ALRM1_MATCH_SEC) {AlarmBits |= ALRM1_MATCH_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_MIN_SEC) {AlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_DY_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_EVERY_SEC;}
        }
    else if (dir == 0) {
        if (ABits==ALRM1_MATCH_EVERY_SEC) {AlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}
        else if (ABits==ALRM1_MATCH_SEC) {AlarmBits |= ALRM1_MATCH_EVERY_SEC;}
        else if (ABits==ALRM1_MATCH_MIN_SEC) {AlarmBits |= ALRM1_MATCH_SEC;}
        else if (ABits==ALRM1_MATCH_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_MIN_SEC;}
        else {AlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}
    }
    else {AlarmBits |= ABits;}

    Serial.print("New Alarm Bits=");
    Serial.println(AlarmBits, BIN);

    Serial.println("Match the coding in the DS32313 Library");

    Serial.print("A1M1 <<7=");
    Serial.println((AlarmBits & 0b00000001) << 7 , BIN);

    Serial.print("A1M2 <<6=");
    Serial.println((AlarmBits & 0b00000010) << 6 , BIN);

    Serial.print("A1M3 <<5=");
    Serial.println((AlarmBits & 0b00000100) << 5 , BIN);

    Serial.print("A1M4 <<4=");
    Serial.println((AlarmBits & 0b00001000) << 4 , BIN);

    Serial.print("ADay=");
    Serial.println(ADay , BIN);
    
    Clock.setA1Time(ADay, AHour, AMinute, ASecond, AlarmBits, ADy, A12h, Apm);

    byte newBits;
    Clock.getA1Time(ADay, AHour, AMinute, ASecond, newBits, ADy, A12h, Apm);  

    Serial.print("New Bits=");
    Serial.println(newBits, BIN);    
    
  } else {
    Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);  
   
    if (dir == 1) {
      if ((ABits>>4)==ALRM2_ONCE_PER_MIN) {AlarmBits = ALRM2_MATCH_MIN;}
      else if ((ABits>>4)==ALRM2_MATCH_MIN) {AlarmBits = ALRM2_MATCH_HR_MIN;}
      else {AlarmBits = ALRM2_ONCE_PER_MIN;}
    }
    if (dir == 0) {
      if ((ABits>>4)==ALRM2_ONCE_PER_MIN) {AlarmBits = ALRM2_MATCH_HR_MIN;}
      else if ((ABits>>4)==ALRM2_MATCH_HR_MIN) {AlarmBits = ALRM2_MATCH_MIN;}
      else {AlarmBits = ALRM2_ONCE_PER_MIN;}
    }
    else {
      AlarmBits=(ABits>>4);
    }
    
    Clock.setA2Time(ADay, AHour, AMinute, AlarmBits, ADy, A12h, Apm);
  }
  
  
}

But when I try to use the same functioning to display the mode on the LCD it goes haywire

void showAlarmMethod(int alarmNum) {

  String myString1="";
  String myString2="";


  byte ADay, AHour, AMinute, ASecond, ABitsOP;
  bool ADy, A12h, Apm;

  if (alarmNum==1){

    myString1 = "Alarm 1 Method:";
    
    Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABitsOP, ADy, A12h, Apm);  

    ABitsOP  = ABitsOP & 0b1111;

    Serial.println("Checking text function ---");

    Serial.print("ABits to check = ");
    Serial.println(ABitsOP, BIN);

    Serial.print("Match ALRM1_MATCH_EVERY_SEC ");
    Serial.println((ABitsOP==ALRM1_MATCH_EVERY_SEC));

    Serial.print("Match ALRM1_MATCH_SEC ");
    Serial.println((ABitsOP==ALRM1_MATCH_SEC));

    Serial.print("Match ALRM1_MATCH_MIN_SEC ");
    Serial.println((ABitsOP==ALRM1_MATCH_MIN_SEC));

    Serial.print("Match ALRM1_MATCH_HR_MIN_SEC ");
    Serial.println((ABitsOP==ALRM1_MATCH_HR_MIN_SEC));

    Serial.print("Match ALRM1_MATCH_DY_HR_MIN_SEC ");
    Serial.println((ABitsOP==ALRM1_MATCH_DY_HR_MIN_SEC));

    if (ABitsOP==ALRM1_MATCH_EVERY_SEC) {myString2 = "Once per Second";}
    else if (ABitsOP==ALRM1_MATCH_SEC) {myString2 = "Seconds Match";}
    else if (ABitsOP==ALRM1_MATCH_MIN_SEC) {myString2 = "Min & Secs Match";}
    else if (ABitsOP==ALRM1_MATCH_HR_MIN_SEC) {myString2 = "Hr, Min & Sec Match";}
    else if (ABitsOP==ALRM1_MATCH_DY_HR_MIN_SEC) {myString2 = "Dy, Hr, Mn & Sec";}
    } else {
    
    Clock.getA2Time(ADay, AHour, AMinute, ABitsOP, ADy, A12h, Apm);  
    
    myString1 = "Alarm 2 Method:";
    
    if ((ABitsOP>>4)==ALRM2_ONCE_PER_MIN) {myString2 = "Once per Minute";}
    else if ((ABitsOP>>4)==ALRM2_MATCH_MIN) {myString2 = "Match Minute";}
    else {myString2 = "Hr, Min & Sec Match";}
  }
  
  displayText(myString1 , myString2);
}

This is the serial print:

18:14:39.085 -> Match ALRM1_MATCH_EVERY_SEC 1
18:14:39.132 -> Match ALRM1_MATCH_SEC 0
18:14:39.132 -> Match ALRM1_MATCH_MIN_SEC 0
18:14:39.178 -> Match ALRM1_MATCH_HR_MIN_SEC 0
18:14:39.178 -> Match ALRM1_MATCH_DY_HR_MIN_SEC 0
18:14:39.223 -> ALRM1_MATCH_EVERY_SEC = 1111
18:14:39.270 -> ALRM1_MATCH_SEC = 1110
18:14:39.270 -> ALRM1_MATCH_MIN_SEC = 1100
18:14:39.316 -> ALRM1_MATCH_HR_MIN_SEC = 1000
18:14:39.362 -> Initial ABits=1110
18:14:39.362 -> Initial AlarmBits=0
18:14:39.409 -> Match ALRM1_MATCH_EVERY_SEC 0
18:14:39.409 -> Match ALRM1_MATCH_SEC 1
18:14:39.455 -> Match ALRM1_MATCH_MIN_SEC 0
18:14:39.455 -> Match ALRM1_MATCH_HR_MIN_SEC 0
18:14:39.503 -> Match ALRM1_MATCH_DY_HR_MIN_SEC 0
18:14:39.550 -> New Alarm Bits=1100
18:14:39.597 -> Match the coding in the DS32313 Library
18:14:39.643 -> A1M1 <<7=0
18:14:39.643 -> A1M2 <<6=0
18:14:39.643 -> A1M3 <<5=10000000
18:14:39.643 -> A1M4 <<4=10000000
18:14:39.689 -> ADay=1
18:14:39.689 -> New Bits=1100
18:14:39.689 -> Checking text function ---
18:14:39.735 -> ABits to check = 1101
18:14:39.781 -> Match ALRM1_MATCH_EVERY_SEC 0
18:14:39.781 -> Match ALRM1_MATCH_SEC 0
18:14:39.828 -> Match ALRM1_MATCH_MIN_SEC 0
18:14:39.828 -> Match ALRM1_MATCH_HR_MIN_SEC 0
18:14:39.873 -> Match ALRM1_MATCH_DY_HR_MIN_SEC 0
18:14:39.920 -> Checking text function ---
18:14:39.920 -> ABits to check = 1101
18:14:39.967 -> Match ALRM1_MATCH_EVERY_SEC 0
18:14:40.013 -> Match ALRM1_MATCH_SEC 0
18:14:40.013 -> Match ALRM1_MATCH_MIN_SEC 0
18:14:40.060 -> Match ALRM1_MATCH_HR_MIN_SEC 0
18:14:40.060 -> Match ALRM1_MATCH_DY_HR_MIN_SEC 0

I can't understand why the same code f]produces a value of 1100 in one routine and 1101 in another :-/

I even copied and pasted the code between functions to ensure I wasn't introducing a typo.

If anyone can save my sanity I'd be very helpful

I can't understand why the same code f]produces a value of 1100 in one routine and 1101 in another :-/

When you declare ABits and ABitsOP in the function they are local variables and not initialized to 0. Explicitly set them to 0 or else you may have some garbage in the memory location.

byte ADay, AHour, AMinute, ASecond, ABits;
byte ADay, AHour, AMinute, ASecond, ABitsOP;

That's it :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:

byte ADay, AHour, AMinute, ASecond, ABitsOP=0b0;

Works perfectly now, cattledog you're a star

Is there a way of "staring" a reply? I've added karma