Insert switch to lcd clock

Hi,
I did this clock thermometer_clock_lcd.ino (3.4 KB)
inspired by this project, but I wish to insert a switch to set the alarm and I do not know how.

How would one switch set an alarm? Is the switch to just enable or disable an alarm hardcoded for some time. Or to set the time and enable and disable the alarm?

More detail of what you want to do would be welcome.

I wish to set the time of the alarm and enable/disable it .

I don't know how you would do that with one switch. Perhaps investigate using a rotary encoder with a built in push switch. Do a search for "arduino rotary encoder set time ds3231" to get some ideas.

Interesting, but for implement this method is enough complicated for me . A method with two switches I think would be easily to me

I tried https://www.youtube.com/watch?v=sK5B9zZ70d4 but I have some errors in compilation "no matching function for call to 'DS3231::DS3231()' ". I used DS3231-master library

You may not have the right DS3231 library installed. There are more than one and they are probably not compatible.

Read the forum guidelines to see how to post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto Format) to indent the code for readability before posting code.

Post the entire text of the error message. It is easy to do. In the IDE on the lower right there is a "copy error" button. Copy and paste the error into a post in code tags. Paraphrasing the error leaves out important information.

the error is :
Arduino: 1.8.16 (Windows Store 1.8.51.0) (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

1_setup:14:8: error: no matching function for call to 'DS3231::DS3231()'

DS3231 clock;

    ^~~~~

In file included from C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\1_setup.ino:13:0:

C:\Users\bogdan\Documents\Arduino\libraries\DS3231/DS3231.h:80:3: note: candidate: DS3231::DS3231(uint8_t, uint8_t)

DS3231(uint8_t data_pin, uint8_t sclk_pin);

^~~~~~

C:\Users\bogdan\Documents\Arduino\libraries\DS3231/DS3231.h:80:3: note: candidate expects 2 arguments, 0 provided

C:\Users\bogdan\Documents\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate: constexpr DS3231::DS3231(const DS3231&)

class DS3231

   ^~~~~~

C:\Users\bogdan\Documents\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate expects 1 argument, 0 provided

C:\Users\bogdan\Documents\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate: constexpr DS3231::DS3231(DS3231&&)

C:\Users\bogdan\Documents\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate expects 1 argument, 0 provided

1_setup:15:1: error: 'RTClib' does not name a type

RTClib rtc;

^~~~~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void display_clock()':

5_display:20:10: error: 'DateTime' does not name a type; did you mean 'Time'?

static DateTime p;

      ^~~~~~~~

      Time

5_display:21:10: error: 'DateTime' does not name a type; did you mean 'Time'?

static DateTime t;

      ^~~~~~~~

      Time

5_display:22:3: error: 't' was not declared in this scope

t = rtc.now();

^

5_display:22:7: error: 'rtc' was not declared in this scope

t = rtc.now();

   ^~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino:22:7: note: suggested alternative: 'getc'

t = rtc.now();

   ^~~

   getc

5_display:24:22: error: 'p' was not declared in this scope

if ( t.minute() != p.minute() ) print_min();

                  ^

5_display:25:20: error: 'p' was not declared in this scope

if ( t.hour() != p.hour() ) { print_hour(); print_apm_str(); }

                ^

5_display:26:19: error: 'p' was not declared in this scope

if ( t.day() != p.day() ) { print_date(); print_dow_str(); }

               ^

5_display:27:21: error: 'p' was not declared in this scope

if ( t.month() != p.month() ) print_mon_str();

                 ^

5_display:28:20: error: 'p' was not declared in this scope

if ( t.year() != p.year() ) print_year();

                ^

5_display:30:3: error: 'p' was not declared in this scope

p = t;

^

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_year()':

5_display:44:27: error: 'class DS3231' has no member named 'getYear'; did you mean 'getTemp'?

lcd.print( 2000 + clock.getYear(), DEC );

                       ^~~~~~~

                       getTemp

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_mon_str()':

5_display:48:24: error: 'class DS3231' has no member named 'getMonth'; did you mean 'getMonthStr'?

lcd.print( moy[clock.getMonth(Century) - 1 ] );

                    ^~~~~~~~

                    getMonthStr

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_date()':

5_display:52:19: error: 'class DS3231' has no member named 'getDate'; did you mean 'setDate'?

add_zero( clock.getDate() );

               ^~~~~~~

               setDate

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_dow_str()':

5_display:57:25: error: 'class DS3231' has no member named 'getDoW'; did you mean 'setDOW'?

lcd.print( dow[ clock.getDoW( ) - 1 ] );

                     ^~~~~~

                     setDOW

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_apm_str()':

5_display:65:16: error: 'class DS3231' has no member named 'getHour'

 if ( clock.getHour(h12, PM) > 11 ) lcd.print( "PM ");

            ^~~~~~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_hour()':

5_display:70:23: error: 'class DS3231' has no member named 'getHour'

uint8_t val = clock.getHour(h12, PM);

                   ^~~~~~~

5_display:72:16: error: 'class DS3231' has no member named 'getHour'

 if ( clock.getHour(h12, PM) > 12 ) val -= 12;

            ^~~~~~~

5_display:73:16: error: 'class DS3231' has no member named 'getHour'

 if ( clock.getHour(h12, PM) == 0 ) val  = 12;

            ^~~~~~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_min()':

5_display:81:19: error: 'class DS3231' has no member named 'getMinute'; did you mean 'getTime'?

add_zero( clock.getMinute() );

               ^~~~~~~~~

               getTime

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_sec()':

5_display:90:19: error: 'class DS3231' has no member named 'getSecond'

add_zero( clock.getSecond() );

               ^~~~~~~~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void print_temperature()':

5_display:104:30: error: 'class DS3231' has no member named 'getTemperature'; did you mean 'getTimeStr'?

currTemp = ( int8_t )clock.getTemperature();

                          ^~~~~~~~~~~~~~

                          getTimeStr

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino: In function 'void set_dow()':

5_display:132:3: error: 'DateTime' was not declared in this scope

DateTime t = rtc.now();

^~~~~~~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\5_display.ino:132:3: note: suggested alternative: 'Time'

DateTime t = rtc.now();

^~~~~~~~

Time

5_display:133:11: error: 't' was not declared in this scope

dow = ( t.year() % 100);

       ^

5_display:139:9: error: 'class DS3231' has no member named 'setDoW'; did you mean 'setDOW'?

clock.setDoW( dow );

     ^~~~~~

     setDOW

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\6_adjust.ino: In function 'void _03()':

6_adjust:60:43: error: 'class DS3231' has no member named 'getYear'; did you mean 'getTemp'?

 case _YEAR    : RotaryCounter = clock.getYear() + 2000 ; break;

                                       ^~~~~~~

                                       getTemp

6_adjust:61:43: error: 'class DS3231' has no member named 'getMonth'; did you mean 'getMonthStr'?

 case _MONTH   : RotaryCounter = clock.getMonth( Century ); break;

                                       ^~~~~~~~

                                       getMonthStr

6_adjust:62:43: error: 'class DS3231' has no member named 'getDate'; did you mean 'setDate'?

 case _DATE    : RotaryCounter = clock.getDate(); break;

                                       ^~~~~~~

                                       setDate

6_adjust:65:43: error: 'class DS3231' has no member named 'getHour'

 case _HOUR    : RotaryCounter = clock.getHour( h12, PM ); break;

                                       ^~~~~~~

6_adjust:66:43: error: 'class DS3231' has no member named 'getMinute'; did you mean 'getTime'?

 case _MINUTE  : RotaryCounter = clock.getMinute(); break;

                                       ^~~~~~~~~

                                       getTime

6_adjust:67:43: error: 'class DS3231' has no member named 'getSecond'

 case _SECOND  : RotaryCounter = clock.getSecond(); break;

                                       ^~~~~~~~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\6_adjust.ino: In function 'void _04()':

6_adjust:81:11: error: 'class DS3231' has no member named 'setYear'

 clock.setYear( RotaryCounter - 2000 );

       ^~~~~~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\6_adjust.ino: In function 'void _05()':

6_adjust:99:11: error: 'class DS3231' has no member named 'setMonth'; did you mean 'setDate'?

 clock.setMonth( RotaryCounter );

       ^~~~~~~~

       setDate

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\6_adjust.ino: In function 'void _06()':

6_adjust:114:16: error: 'class DS3231' has no member named 'getYear'; did you mean 'getTemp'?

if ( ( clock.getYear() % 4 ) == 0 ) dom[2] = 29; else dom[2] = 28;

            ^~~~~~~

            getTemp

6_adjust:115:35: error: 'class DS3231' has no member named 'getMonth'; did you mean 'getMonthStr'?

if ( RotaryCounter > dom[ clock.getMonth(Century) ] ) RotaryCounter = 1;

                               ^~~~~~~~

                               getMonthStr

6_adjust:116:56: error: 'class DS3231' has no member named 'getMonth'; did you mean 'getMonthStr'?

if ( RotaryCounter < 1 ) RotaryCounter = dom[ clock.getMonth(Century) ];

                                                    ^~~~~~~~

                                                    getMonthStr

6_adjust:119:34: error: no matching function for call to 'DS3231::setDate(volatile int16_t&)'

 clock.setDate( RotaryCounter );

                              ^

In file included from C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\1_setup.ino:13:0:

C:\Users\bogdan\Documents\Arduino\libraries\DS3231/DS3231.h:84:8: note: candidate: void DS3231::setDate(uint8_t, uint8_t, uint16_t)

void setDate(uint8_t date, uint8_t mon, uint16_t year);

    ^~~~~~~

C:\Users\bogdan\Documents\Arduino\libraries\DS3231/DS3231.h:84:8: note: candidate expects 3 arguments, 1 provided

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\6_adjust.ino: In function 'void _09()':

6_adjust:158:11: error: 'class DS3231' has no member named 'setHour'

 clock.setHour( RotaryCounter );

       ^~~~~~~

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\6_adjust.ino: In function 'void _10()':

6_adjust:175:11: error: 'class DS3231' has no member named 'setMinute'; did you mean 'setTime'?

 clock.setMinute( RotaryCounter );

       ^~~~~~~~~

       setTime

C:\Users\bogdan\AppData\Local\Temp\arduino_modified_sketch_942909\6_adjust.ino: In function 'void _11()':

6_adjust:197:9: error: 'class DS3231' has no member named 'setSecond'

clock.setSecond( RotaryCounter );

     ^~~~~~~~~

Multiple libraries were found for "LiquidCrystal_I2C.h"

Used: C:\Users\bogdan\Documents\Arduino\libraries\LiquidCrystal_I2C

Not used: C:\Users\bogdan\Documents\Arduino\libraries\New-LiquidCrystal-master

Multiple libraries were found for "DS3231.h"

Used: C:\Users\bogdan\Documents\Arduino\libraries\DS3231

Not used: C:\Users\bogdan\Documents\Arduino\libraries\DS3231-master

exit status 1

no matching function for call to 'DS3231::DS3231()'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please go back and put the errors in code tags.

Is this the DS3231 library that you have installed? I think that that is the required library.

Is the linked library properly installed? Here is a Sparkfun tutorial on how to install libraries.

There are several libraries with the name DS3231. You must use the one intended for the code. Just cause a library is named DS3231 does not mean that it is compatible.

My question is "did you install the DS3231 library from the linked location"?

from here https://github.com/NorthernWidget/DS3231

I found a good library https://github.com/PatriceG/ArduiBodet I like how it works, it's a shame it doesn't have an alarm