HI everyone! Need help

Hi everyone! As title say, i need help for my first little project, the "digital alarm clock".
I write a little code that show time (hh:mins:sec) and under a message say "HAVE A NICE DAY".
"What's the problem?", you think.
Instead of that message, i want show the date and, with a button, set the clock and the date.
I use yet two button for set minute and hour. I post the code, hoping that someone help, and suggest, me something helpful to improve my first project. Thanks.

#include <LCD.h>
#include <LiquidCrystal.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //impostazione indirizzo del display e pin del display LCD

int sec,mins,ora; 
char buf1[17];
int val1=0, val2=0;
int puls1=2, puls2=3; 


void setup() {
  lcd.begin(16,2); //Start the LCD I2C 16x2
  pinMode(puls1, INPUT);
  pinMode(puls2, INPUT);
}

void loop(){
lcd.clear();


for(ora=0; ora<24; ora++)
 for(mins=0; mins<60; mins++)
   for(sec=0; sec<60; sec++)
 {

 
 val1 = digitalRead(puls1);
 val2 = digitalRead(puls2);


 //set hours
 if(val1==1){
   lcd.clear();
   sprintf(buf1, "    %02d:%02d:%02d",ora++,mins,sec);
   lcd.print(buf1);
   lcd.setCursor(1,1);
   lcd.print("HAVE A NICE DAY"); 
   delay(100);}

  //check hour
  if(ora > 23){
   ora = 0;
   lcd.clear();
   sprintf(buf1, "    %02d:%02d:%02d",0,mins,sec);
   lcd.print(buf1); 
   lcd.setCursor(1,1);
   lcd.print("HAVE A NICE DAY"); 
   delay(100);}

  
//set minutes
  if(val2==1){
   lcd.clear();
   sprintf(buf1, "    %02d:%02d:%02d",ora,mins++,sec);
   lcd.print(buf1);
   lcd.setCursor(1,1);
   lcd.print("HAVE A NICE DAY"); 
   delay(100);}

  //check minutes
  if(mins > 59){
   mins = 0;
   lcd.clear();
  sprintf(buf1, "    %02d:%02d:%02d",ora++,0,sec);
  lcd.print(buf1);
  lcd.setCursor(1,1);
  lcd.print("HAVE A NICE DAY"); 
  delay(100);}

 //Show final result on LCD screen
 lcd.setCursor(0, 0);
 sprintf(buf1, "    %02d:%02d:%02d",ora,mins,sec);
 lcd.print(buf1);
 lcd.setCursor(1,1);
 lcd.print("HAVE A NICE DAY");

 delay(1000); //Seconds
 }
 

}

prova.ino (1.78 KB)

Almost everyone who starts a Thread on the Forum is looking for help. I suggest you modify your Original Post and change the title so it tells people what you need help with.

And you need to tell us what your program actually does and what you want it to do that is different.

I suspect there are dozens of other Threads that deal with setting the time on clocks.

...R

Sorry, i'm newbie on this site and i don't know where open thread, ok i try to use your advice.....however thank you! :slight_smile: