consigli sullo sketch di un calendario automatizzato

salve ancora,

il progetto da me ideato è a metà dell’opera, volevo avere dei consigli su come sistemare e riordinare il mio codice.

il progetto consiste in:

1- display a 7 segmenti che segna l’ora
2- display a 7 segmenti che segna l’anno
3- servo che segna il numero dei giorni del mese
4- uno step motor che segna i mesi (ancora da comprare e da mettere nel codice)
5- 7 led che segnano i giorni della settimana
6- rotary encoder, piu qualche interruttore, per settare il tutto (ancora da aggiungere)
8- un voltmetro che conta i secondi (ancora da aggiungere ma già testato)

questo progetto verrà tutto racchiuso in una scatola con pezzi vintage un po steampunk posterò una foto a progetto finito.

volevo sapere cosa ne pensate dello sketch da me copiato/scritto/assemblato/modificato

e se posso abbreviare un po di passaggi perchè mi sembra molto lungo e incasinato
qui lo skatch:

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

// Set to false to display time in 12 hour format, or true to use 24 hour:
#define TIME_24_HOUR      true

// I2C address of the display.  Stick with the default address of 0x70
// unless you've changed the address jumpers on the back of the display.
#define DISPLAY_ADDRESS1   0x70 //ore
#define DISPLAY_ADDRESS2   0x71 //anni

// Create display and DS1307 objects.  These are global variables that
// can be accessed from both the setup and loop function below.
Adafruit_7segment clockDisplay = Adafruit_7segment();
Adafruit_7segment yearsDisplay = Adafruit_7segment();


Multiplexer multiplexer;

//int ledGiorni[7] = {2, 3, 4, 5, 6, 7, 8}; // reparto giorni con i pin da cambiare quando si mette lo sdoppiatore


#if defined(ARDUINO_ARCH_SAMD)  // for Zero, output on USB Serial console
#define Serial SerialUSB
#endif

RTC_DS1307 rtc;

int hours = 0;
int minutes = 0;
int seconds = 0;
int years = 0;

// Remember if the colon was drawn on the display so it can be blinked
// on and off every second.
bool blinkColon = false;

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

Servo servo1;
Servo servo2; //gradi invertiti
int posServo1 = 0;
int posServo2 = 0;

int val1;
int val2;


void setup () {
  while (!Serial);  // for Leonardo/Micro/Zero

  Serial.begin(9600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  // Setup the display.
  clockDisplay.begin(DISPLAY_ADDRESS1);
  yearsDisplay.begin(DISPLAY_ADDRESS2);

  // Setup the DS1307 real-time clock.
  rtc.begin();

  // Set the DS1307 clock if it hasn't been set before.
  bool setClockTime = !rtc.isrunning() /*true*/;
  // Alternatively you can force the clock to be set again by
  // uncommenting this line:
  //setClockTime = true;
  if (setClockTime) {
    Serial.println("Setting DS1307 time!");
    // This line sets the DS1307 time to the exact date and time the
    // sketch was compiled:
    rtc.adjust(DateTime(2015, 12, 26, 17, 39, 30));
    // Alternatively you can set the RTC with an explicit date & time,
    // for example to set January 21, 2014 at 3am you would uncomment:
    //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }

  multiplexer.begin (8, 9, 10, 11, Multiplexer::NO_INHIBIT);
  
  servo1.attach(3);
  servo2.attach(4);

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    //rtc.adjust(DateTime(2015, 12, 19, 16, 17, 00));
    // 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();

  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(" (");
  Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
  Serial.print(") ");
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();

  Serial.println();
  delay(1000);

  hours = now.hour();
  minutes = now.minute();
  years = now.year ();

 
  int displayValue2 = years;
  yearsDisplay.print(displayValue2);
  yearsDisplay.writeDisplay();
  
  
  
  // Show the time on the display by turning it into a numeric
  // value, like 3:30 turns into 330, by multiplying the hour by
  // 100 and then adding the minutes.
  int displayValue = hours * 100 + minutes;

  // If we're using 12-hour format and it's past noon then subtract
  // 1200 from the display value.
  if (!TIME_24_HOUR && hours > 11) {
    displayValue -= 1200;
  }

  // Now print the time value to the display.
  clockDisplay.print(displayValue, DEC);

  // Blink the colon by flipping its value every loop iteration
  // (which happens every second).
  blinkColon = !blinkColon;
  clockDisplay.drawColon(blinkColon);

  // Now push out to the display the new values that were set above.
  clockDisplay.writeDisplay();

  // Pause for a second for time to elapse.  This value is in milliseconds
  // so 1000 milliseconds = 1 second.
  //delay(500);

  // Now increase the seconds by one.
  seconds += 1;
  // If the seconds go above 59 then the minutes should increase and
  // the seconds should wrap back to 0.
  if (seconds > 59) {
    seconds = 0;
    minutes += 1;
    // Again if the minutes go above 59 then the hour should increase and
    // the minutes should wrap back to 0.
    if (minutes > 59) {
      minutes = 0;
      hours += 1;
      // Note that when the minutes are 0 (i.e. it's the top of a new hour)
      // then the start of the loop will read the actual time from the DS1307
      // again.  Just to be safe though we'll also increment the hour and wrap
      // back to 0 if it goes above 23 (i.e. past midnight).
      if (hours > 23) {
        hours = 0;
      }
    }
  }




      // led dei giorni della settimana da cambiare quando si installa il chip che sdoppia

      if (now.dayOfTheWeek() == 0) {      //domenica
        multiplexer.select (6);
      }
      else if (now.dayOfTheWeek() == 1) { //lunedi
        multiplexer.select (0);
      }
      else if (now.dayOfTheWeek() == 2) { //mardedi
        multiplexer.select (1);
      }
      else if (now.dayOfTheWeek() == 5) { //mercoledi
        multiplexer.select (2);
      }
      else if (now.dayOfTheWeek() == 4) { //giovedi
        multiplexer.select (3);
      }
      else if (now.dayOfTheWeek() == 5) { //venerdi
        multiplexer.select (4);
      }
      else if (now.dayOfTheWeek() == 6) { //sabato
        multiplexer.select (5);
      }

      val1 = (now.day());
      servo1.write((val1 * 3) + 45);

      val2 = (now.month());
      servo2.write(val2 * 15);

  }