Programming troubles with adding Servos to digital RTC alarm clock

TLDR:
Have gotten digital alarm clock to work but having troubles with attaching and programming 2 SG90 servo's for hours and minutes display.
I am unsure of how I can accurately describe this, so I have attached a couple of videos

Hey all. I am more skilled in 3d design than I am with programming and I am looking for advice/assistance from anyone with insightful knowledge.

So far I have managed to make a digital alarm clock.
I am using:

  • a DS1307 rtc
  • a 16x2 LCD
  • an assortment of buttons

I am now trying to add 2 SG90 servos, 1 for hours and 1 for minutes.
Trouble is, my servos seem to initialize but do not actually move to the times on the RTC (which the arduino has displayed on the LCD).

Here is my code:
Shortened code: (where I suspect the issue is)

void loop () {


    DateTime now = rtc.now();

    if((digitalRead(P1)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = 86400; // Move time ahead one day (maybe)
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P1)==HIGH)
      {
   uint32_t deltaT = 3600; // Move time ahead one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }
    }

    

     if((digitalRead(P2)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = -86400; // Move time back one day (maybe)
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P2)==HIGH)
      {
   uint32_t deltaT = -3600; // Move time back one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }

    }


   if((digitalRead(P3)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = 1; // Move time ahead one second
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P3)==HIGH)
      {
   uint32_t deltaT = 60; // Move time ahead one minute
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }
    }

    

     if((digitalRead(P4)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = -1; // Move time back one second
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P4)==HIGH)
      {
   uint32_t deltaT = -60; // Move time back one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }

    }

    lcd.print(now.hour(), DEC);
   
    lcd.print(":");
    lcd.print(now.minute(), DEC);
  
    lcd.print(":");
    lcd.print(now.second(), DEC);
    lcd.setCursor(0, 1);
    lcd.print(now.day(), DEC);
    lcd.print(":");
    lcd.print(now.month(), DEC);
    lcd.print(":");
    lcd.print(now.year(), DEC);
    delay(250);
    lcd.clear();
    lcd.setCursor(0, 0);


 hoursdegree = 180-(now.hour()*7.5);
    hours.write(hoursdegree);

      minutesdegree = 180-(now.minute()*3);
     minutes.write(minutesdegree); 

//clockfaceHands();

  
}

void clockfaceHands(){
  DateTime now = rtc.now();
hoursdegree = (180-(now.hour()*7.5));

minutesdegree = (180-(now.minute()*3));


    minutes.write(minutesdegree);  
    hours.write(hoursdegree); // tell servo to go to position in variable

}

Full code:

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include "RTClib.h"
#include <LiquidCrystal.h>
#include <Servo.h>
RTC_DS1307 rtc;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

//RTC clock - Matthew Lim

//references
//*OLD* library info https://github.com/davidhbrown/RealTimeClockDS1307/blob/master/RealTimeClockDS1307.h ***ditched this library as it was missing features moved to RTCLIB
//RTCLIB library info https://github.com/adafruit/RTClib/blob/master/RTClib.h

//bare source 1: https://www.instructables.com/Arduino-Real-Time-Clock-DS1307/
//interesting idea to move to different library: https://arduino.stackexchange.com/questions/3354/why-is-my-real-time-clock-getting-the-wrong-time-from-my-pc
//https://www.arduino.cc/en/Reference/LiquidCrystal LCD library
//realtime updating rtc time https://forum.arduino.cc/index.php?topic=555628.0
// concept of adding double action buttons https://forum.arduino.cc/index.php?topic=512477.0

//buttons

int PM=6; //button modifier (using pin 6) - will try to make the other buttons change the days and the seconds when held down.
int P1=7; //button + hours (using pin 7)
int P2=8; //button - hours (using pin 8)
int P3=9; //button + minutes (using pin 9)
int P4=10; //button - minutes (using pin 10)

//servos
Servo hours; // hours is using pin 1
Servo minutes; // minutes is using pin 0
int hoursdegree = 0;
int minutesdegree = 0;

void setup () {
  Serial.begin(57600);
lcd.begin(16,2); 
  pinMode(A3, OUTPUT);
  digitalWrite(A3, HIGH);
  pinMode(A2, OUTPUT);
  digitalWrite(A2, LOW);

  pinMode(PM, INPUT);
  pinMode(P1, INPUT); //allows program to recognise that we are using buttons
  pinMode(P2, INPUT); 
  pinMode(P3, INPUT);
  pinMode(P4, INPUT);

  minutes.attach(0);
  hours.attach(1);




#ifndef ESP8266
  while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    abort();
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }

  // When time needs to be re-set on a previously configured device, the
  // following line sets the RTC to the date & time this sketch was compiled
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  // This line sets the RTC with an explicit date & time, for example to set
  // January 21, 2014 at 3am you would call:
  // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

void loop () {






    DateTime now = rtc.now();

    if((digitalRead(P1)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = 86400; // Move time ahead one day (maybe)
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P1)==HIGH)
      {
   uint32_t deltaT = 3600; // Move time ahead one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }
    }

    

     if((digitalRead(P2)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = -86400; // Move time back one day (maybe)
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P2)==HIGH)
      {
   uint32_t deltaT = -3600; // Move time back one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }

    }





   if((digitalRead(P3)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = 1; // Move time ahead one second
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P3)==HIGH)
      {
   uint32_t deltaT = 60; // Move time ahead one minute
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }
    }

    

     if((digitalRead(P4)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = -1; // Move time back one second
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P4)==HIGH)
      {
   uint32_t deltaT = -60; // Move time back one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }

    }












   

    lcd.print(now.hour(), DEC);
   
    lcd.print(":");
    lcd.print(now.minute(), DEC);
  
    lcd.print(":");
    lcd.print(now.second(), DEC);
    lcd.setCursor(0, 1);
    lcd.print(now.day(), DEC);
    lcd.print(":");
    lcd.print(now.month(), DEC);
    lcd.print(":");
    lcd.print(now.year(), DEC);
    delay(250);
    lcd.clear();
    lcd.setCursor(0, 0);
 

 hoursdegree = 180-(now.hour()*7.5);
    hours.write(hoursdegree);

      minutesdegree = 180-(now.minute()*3);
     minutes.write(minutesdegree); 

//clockfaceHands();

  
}

void clockfaceHands(){
  DateTime now = rtc.now();
hoursdegree = (180-(now.hour()*7.5));

minutesdegree = (180-(now.minute()*3));


    minutes.write(minutesdegree);  
    hours.write(hoursdegree); // tell servo to go to position in variable

}

Here are some videos of the problem(s) I am experiencing:

Video 1:
Caption: Sweep running with one variable between the two servos.

Video 2:
Caption: The program running (with the code pasted above)

Any help would be appreciated.
Thank you - Matt

Which Arduino board are you using ?

On most of them pins 0 and 1 are used for hardware Serial so it is inadvisable to use them for anything else as you do. Does the Servo library Sweep example work for you ?

An arduino UNO, just with a small breadboard attached with double sided tape to the rear.

I have used all of the pins bar for one of them so i will need to use one of the hardware serial ports in the end anyway.

Video 1 is of sweep running.

Thanks for your reply.

UKHeliBob:
Which Arduino board are you using ?

On most of them pins 0 and 1 are used for hardware Serial so it is inadvisable to use them for anything else as you do. Does the Servo library Sweep example work for you ?

Have you used all of the analogue in pins A0 to A5 ?

UKHeliBob:
Have you used all of the analogue in pins A0 to A5 ?

I have only used A4 and A5, would I be able to use them as regular pins?
Also in regards to my code, how do you think I could rewrite the loop so that I can ensure that the servo positions are updating every loop? So far as seen in video 2, it seems like the servo movements are independent of what is displaying on the LCD. How can I ensure that they work simultaneously?
Thanks

@pogchampion, you seem to have a lot of code in the program in your Original Post that has nothing to do with the problem you describe - for example the code to update the time.

Can you just post a program that has the absolute minimum in it to demonstrate the problem.

It might be an idea to have the servos show seconds and minutes while testing as the response will be quicker.

...R

I have only used A4 and A5, would I be able to use them as regular pins?

You can use any of the analogue pins as digital pins

Your multiple other posts about your problem in different sections of the forum, none of which had replies, have been deleted

Cross-posting is against the rules of the forum.

The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Robin2:
@pogchampion, you seem to have a lot of code in the program in your Original Post that has nothing to do with the problem you describe - for example the code to update the time.

Can you just post a program that has the absolute minimum in it to demonstrate the problem.

It might be an idea to have the servos show seconds and minutes while testing as the response will be quicker.

...R

Thanks for your suggestion. I have added a snippet of code of just the loop which is where I suspect the problem is.

UKHeliBob:
Your multiple other posts about your problem in different sections of the forum, none of which had replies, have been deleted

Cross-posting is against the rules of the forum.

The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Okay, sorry about that

pogchampion:
Thanks for your suggestion. I have added a snippet of code of just the loop which is where I suspect the problem is.

I did not mean a snippet - problems are often in the part you are not looking at. I meant for you to post a complete program that has the minimum needed to illustrate the problem.

And please include the program in your next Post so we don't have to go back and re-read earlier Posts.

...R

I tried adding very rudimentary code to try and help the servos match the hour and minutes but it does not work. I would like advice and guidance on whether I have written it properly as well as reasoning for the (lack of) compliance from the servo motors. Thank you.

What I added: (just placed in the bottom of the loop)

    //----------now.hour()-----------------//
    if (now.hour() == 1) hours.write(165);
    if (now.hour() == 2) hours.write(150);
    if (now.hour() == 3) hours.write(135);
    if (now.hour() == 4) hours.write(120);
    if (now.hour() == 5) hours.write(105);
    if (now.hour() == 6) hours.write(90);
    if (now.hour() == 7) hours.write(75);
    if (now.hour() == 8) hours.write(60);
    if (now.hour() == 9) hours.write(45);
    if (now.hour() == 10) hours.write(30);
    if (now.hour() == 11) hours.write(15);
    if (now.hour() == 12) hours.write(0);

    if (now.hour() == 13) hours.write(165);
    if (now.hour() == 14) hours.write(150);
    if (now.hour() == 15) hours.write(135);
    if (now.hour() == 16) hours.write(120);
    if (now.hour() == 17) hours.write(105);
    if (now.hour() == 18) hours.write(90);
    if (now.hour() == 19) hours.write(75);
    if (now.hour() == 20) hours.write(60);
    if (now.hour() == 21) hours.write(45);
    if (now.hour() == 22) hours.write(30);
    if (now.hour() == 23) hours.write(15);
    if (now.hour() == 0) hours.write(0);
    
    //--------------now.minute()--------------//
    if (now.minute() == 0) minutes.write(0);
    if (now.minute() == 1) minutes.write(3);
    if (now.minute() == 2) minutes.write(6);
    if (now.minute() == 3) minutes.write(9);
    if (now.minute() == 4) minutes.write(12);
    if (now.minute() == 5) minutes.write(15);
    if (now.minute() == 6) minutes.write(18);
    if (now.minute() == 7) minutes.write(21);
    if (now.minute() == 8) minutes.write(24);
    if (now.minute() == 9) minutes.write(27);
    if (now.minute() == 10) minutes.write(30);
    if (now.minute() == 11) minutes.write(33);
    if (now.minute() == 12) minutes.write(36);
    if (now.minute() == 13) minutes.write(39);
    if (now.minute() == 14) minutes.write(42);
    if (now.minute() == 15) minutes.write(45);
    if (now.minute() == 16) minutes.write(48);
    if (now.minute() == 17) minutes.write(51);
    if (now.minute() == 18) minutes.write(54);
    if (now.minute() == 19) minutes.write(57);
    if (now.minute() == 20) minutes.write(60);
    if (now.minute() == 21) minutes.write(63);
    if (now.minute() == 22) minutes.write(66);
    if (now.minute() == 23) minutes.write(69);
    if (now.minute() == 24) minutes.write(72);
    if (now.minute() == 25) minutes.write(75);
    if (now.minute() == 26) minutes.write(78);
    if (now.minute() == 27) minutes.write(81);
    if (now.minute() == 28) minutes.write(84);
    if (now.minute() == 29) minutes.write(87);
    if (now.minute() == 30) minutes.write(90);
    if (now.minute() == 31) minutes.write(93);
    if (now.minute() == 32) minutes.write(96);
    if (now.minute() == 33) minutes.write(99);
    if (now.minute() == 34) minutes.write(102);
    if (now.minute() == 35) minutes.write(105);
    if (now.minute() == 36) minutes.write(108);
    if (now.minute() == 37) minutes.write(111);
    if (now.minute() == 38) minutes.write(114);
    if (now.minute() == 39) minutes.write(117);
    if (now.minute() == 40) minutes.write(120);
    if (now.minute() == 41) minutes.write(123);
    if (now.minute() == 42) minutes.write(126);
    if (now.minute() == 43) minutes.write(129);
    if (now.minute() == 44) minutes.write(132);
    if (now.minute() == 45) minutes.write(135);
    if (now.minute() == 46) minutes.write(138);
    if (now.minute() == 47) minutes.write(141);
    if (now.minute() == 48) minutes.write(144);
    if (now.minute() == 49) minutes.write(147);
    if (now.minute() == 50) minutes.write(150);
    if (now.minute() == 51) minutes.write(153);
    if (now.minute() == 52) minutes.write(156);
    if (now.minute() == 53) minutes.write(159);
    if (now.minute() == 54) minutes.write(162);
    if (now.minute() == 55) minutes.write(165);
    if (now.minute() == 56) minutes.write(168);
    if (now.minute() == 57) minutes.write(171);
    if (now.minute() == 58) minutes.write(174);
    if (now.minute() == 59) minutes.write(177);

Video with new code:

Have you moved the servos off pins 0 and 1 ?

Please post your complete program as it is now

There is a much smarter way of mapping an output angle to a number by using arrays

Hi thanks for your help so far. I managed to fix the previous problem and now i've run into a new one.

I have been trying several methods to make a new menu for configuring the alarm. I tried using the onebutton library to no avail, likely because i also need my modifier button to change the current time when it is held down, hence i had kept the original code which did not use the onebutton library. I also tried using if((digital blah)&&(digitalblah)&&(digitalblah)&&(digitalblah) to activate the second menu but it did not work. I also tried doing the same but by putting it all around my original button code. I tried also having the day up and seconds down buttons (the two centre buttons) activate the menu switch code but this did not work either.
It would be good if someone could look at my menu switch code itself as i am not too confident on how good it might be. I have been testing by using the Buzz(); function as it lets me know if the code went through but otherwise I am not using an LED.

Here is my code:

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include "RTClib.h"
#include "OneButton.h"   
#include <OneButton.h>   
#include <LiquidCrystal.h>
#include <Servo.h>

RTC_DS1307 rtc;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

//RTC clock - Matthew Lim

//references
//*OLD* library info https://github.com/davidhbrown/RealTimeClockDS1307/blob/master/RealTimeClockDS1307.h ***ditched this library as it was missing features moved to RTCLIB
//RTCLIB library info https://github.com/adafruit/RTClib/blob/master/RTClib.h

//bare source 1: https://www.instructables.com/Arduino-Real-Time-Clock-DS1307/
//interesting idea to move to different library: https://arduino.stackexchange.com/questions/3354/why-is-my-real-time-clock-getting-the-wrong-time-from-my-pc
//https://www.arduino.cc/en/Reference/LiquidCrystal LCD library
//realtime updating rtc time https://forum.arduino.cc/index.php?topic=555628.0
// concept of adding double action buttons https://forum.arduino.cc/index.php?topic=512477.0

//buttons

int PM=6; //button modifier (using pin 6) - will try to make the other buttons change the days and the seconds when held down.
//OneButton onebuttonmodifier(6, true);
int P1=7; //button + hours (using pin 7)
int P2=8; //button - hours (using pin 8)
int P3=9; //button + minutes (using pin 9)
int P4=10; //button - minutes (using pin 10)

//servos
Servo hours; // hours is using pin 1
Servo minutes; // minutes is using pin 0
int hoursdegree = 0;
int minutesdegree = 0;

//buzzer
const int buzzer = 13;

//alarm stuff
bool mondayalarm = false;
bool tuesdayalarm = false;
bool wednesdayalarm = false;
bool thursdayalarm = false;
bool fridayalarm = false;
bool saturdayalarm = false;
bool sundayalarm = false;

int alarmhour = -1;
int alarmminute = -1;
int alarmsecond = -1;

//display
int lcddisplay = 1;
//1 would just be the regular time display
//2 would be the alarm display

void setup () {
  Serial.begin(57600);
lcd.begin(16,2); 
  pinMode(A3, OUTPUT);
  digitalWrite(A3, HIGH);
  pinMode(A2, OUTPUT);
  digitalWrite(A2, LOW);

  pinMode(PM, INPUT);
  pinMode(P1, INPUT); //allows program to recognise that we are using buttons
  pinMode(P2, INPUT); 
  pinMode(P3, INPUT);
  pinMode(P4, INPUT);

  minutes.attach(A0);
  hours.attach(A1);

  pinMode(buzzer, OUTPUT);

 // onebuttonmodifier.attachDoubleClick(modifierdoubleclick);




#ifndef ESP8266
  while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    abort();
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running, let's set the time!");
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  }

}


void loop () {

   DateTime now = rtc.now();


if (lcddisplay ==1)
{
  lcdPrintdisplay1;
  }

if (lcddisplay ==2)
{
  lcdPrintdisplay2;
  }

alarmAdjustMode();
timeAdjustButtons();
lcdPrintdisplay1();
clockfaceHands();


if ((now.hour() == alarmhour) && (now.minute() == alarmminute)){
      Buzz();
      }


//onebuttonmodifier.tick();
  

      
}

void timeAdjustButtons(){


    if((digitalRead(P1)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = 86400; // Move time ahead one day (maybe)
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P1)==HIGH)
      {
   uint32_t deltaT = 3600; // Move time ahead one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }
    }

    

     if((digitalRead(P2)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = -86400; // Move time back one day (maybe)
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P2)==HIGH)
      {
   uint32_t deltaT = -3600; // Move time back one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }

    }





   if((digitalRead(P3)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = 1; // Move time ahead one second
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P3)==HIGH)
      {
   uint32_t deltaT = 60; // Move time ahead one minute
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }
    }

    

     if((digitalRead(P4)==HIGH)&&(digitalRead(PM)==HIGH))
  {
    uint32_t deltaT = -1; // Move time back one second
rtc.adjust(rtc.now() + TimeSpan(deltaT));
  }
    else{
      if(digitalRead(P4)==HIGH)
      {
   uint32_t deltaT = -60; // Move time back one hour
   rtc.adjust(rtc.now() + TimeSpan(deltaT));
      }

    }

  
  
  }




void clockfaceHands(){
  DateTime now = rtc.now();
hoursdegree = (180-(now.hour()*7.5));

minutesdegree = (180-(now.minute()*3));


    minutes.write(minutesdegree);  
    hours.write(hoursdegree); // tell servo to go to position in variable

}




void Buzz() {
    tone(buzzer, 1000); // Send 1KHz sound signal...
    delay(500);        // ...for 1 sec
    noTone(buzzer);     // Stop sound...
    delay(500);        // ...for 1sec
  }

//void modifierdoubleclick(){

//if (lcddisplay ==3){
 // int lcddisplay = 1; 
  //}
 // else
 // {
 // lcddisplay ++;
  // }

//Buzz();

  
  //}

void lcdPrintdisplay1(){

  DateTime now = rtc.now();

    lcd.print(now.hour(), DEC);
    lcd.print(":");
    lcd.print(now.minute(), DEC);
    lcd.print(":");
    lcd.print(now.second(), DEC);
    lcd.setCursor(0, 1);
    lcd.print(now.day(), DEC);
    lcd.print(":");
    lcd.print(now.month(), DEC);
    lcd.print(":");
    lcd.print(now.year(), DEC);
    delay(250);
    lcd.clear();
    lcd.setCursor(0, 0);

  
  }



void lcdPrintdisplay2(){

lcd.setCursor(0, 0);
lcd.print("Set Hrs and Mns");
lcd.setCursor(0, 1);
lcd.print(alarmhour, DEC);     //lcd.print(alarmhour);
lcd.print(":");
lcd.print(alarmminute, DEC);      //lcd.print(alarmminute);

 if(digitalRead(P1)==HIGH)
      {
   alarmhour++;
      }

 if(digitalRead(P2)==HIGH)
      {
   alarmhour-1;
      }

  if(digitalRead(P3)==HIGH)
      {
  alarmminute++;
      }

   if(digitalRead(P4)==HIGH)
      {
  alarmminute-1;
      }
      lcd.clear();

}

void lcdPrintdisplay3() {
lcd.setCursor(0,0);
lcd.print("Mon");
lcd.print(":");
lcd.print("");
  
  }

void alarmAdjustMode() {

//if((digitalRead(P2)==HIGH)&&(digitalRead(P3)==HIGH))
 // {
//if (lcddisplay ==3){
 // int lcddisplay = 1; 
  //}
 //else
 //{
 //lcddisplay +1;
 // }
  //  Buzz();
 // }
  
  }

Any help with my code would be greatly appreciated.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.