Changing RTC3231 time & date

I have been trying to learn how to change the RTC time & date i haven't don't know too much on scripting except for what I learned online I'm not using traditional setup i am using mcp32017 chips and LED's. I have the clock working and the date but I realized when there is no power and the battery needs to replace plus time change for spring and fall I needed to change the time. I would post my hole script but its a bit long due to the LED's here is part I would say to give an example.

// one of a few mcp chips
mcp1.begin();
  mcp1.pinMode(0, OUTPUT);//4
  mcp1.pinMode(1, OUTPUT);//3
  mcp1.pinMode(2, OUTPUT);//2
  mcp1.pinMode(3, OUTPUT);//1
  mcp1.pinMode(4, OUTPUT);//55
  mcp1.pinMode(5, OUTPUT);//50
  mcp1.pinMode(6, OUTPUT);//45
  mcp1.pinMode(7, OUTPUT);//40
  mcp1.pinMode(8, OUTPUT);//35
  mcp1.pinMode(9, OUTPUT);//30
  mcp1.pinMode(10, OUTPUT);//25
  mcp1.pinMode(11, OUTPUT);//20
  mcp1.pinMode(12, OUTPUT);//15
  mcp1.pinMode(13, OUTPUT);//10
  mcp1.pinMode(14, OUTPUT);//5

// to keep the led's off if correct time
for (int i=0; i<15; i++) {
  mcp1.digitalWrite(i, LOW);
}

for (int i=0; i<12; i++) {
  mcp2.digitalWrite(i, LOW);
}

for (int i=0; i<12; i++) {
  mcp3.digitalWrite(i, LOW);
}

for (int i=0; i<15; i++) {
  mcp4.digitalWrite(i, LOW);
}

for (int i=0; i<16; i++) {
  mcp5.digitalWrite(i, LOW);
}

// just one part of time script to turn on led's 
if (now.minute() % 5 == 1)
    for (int i=0; i<1; i++) {
     mcp1.digitalWrite(i, HIGH);
}

  if (now.minute() % 5 == 2)
   for (int i=0; i<2; i++) {
     mcp1.digitalWrite(i, HIGH);
}

  if (now.minute() % 5 == 3) 
    for (int i=0; i<3; i++) {
     mcp1.digitalWrite(i, HIGH);
}
  
  if (now.minute() % 5 == 4) 
    for (int i=0; i<4; i++) {
     mcp1.digitalWrite(i, HIGH);
}

now I know its small but its an example of how I have the script and granted i get I should not have to change this main script to work it; the time change should be small if I'm not mistaken i was thinking of having the group of led's flash for when the time change so for minutes would flash to set time so if its already 2 only 2 led's would flash once you hit the button to change to 3 then 3 led's would flash.

what you posted has nothing to do with your ask. You need to write code to handle time changes, so add buttons, decide how this will work etc... flashing the numbers (leds) is just a matter of turning them on and off like the blink example (or better "blink without delay")

The OneButton library from Matthias Hertel might help you get started to handle the buttons.

There are no scripts on the Arduino. Only sketches. That is actually just another word for "code" or "programs". But scripts refer to interpreted command lines in a shell command language.

Google might find you few clocks with examples in how to change the time settings whilst your sketch is running

Daylight savings time can be handled automatically if you set the RTC to UTC time and use either the TimeZone library, or native C time library to calculate the local time.

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