// // ######################### // # HORLOGE DES VOLETS # // ######################### // # Guy Magli 14.12.2020 # // ######################### // # Conception, cablages # // # mises a jour, # // # contact... # // # www.magli.fr # // ######################### // // Afin d'eviter les problemes d'affichage et d'impression les signes diacritiques // ont ete retires des commentaires et des chaines de caracteres. // // ! ======================== ! // ! LIBRAIRIES ET PARAMETRES ! // ! ======================== ! // #include // Peripheriques. #include // Moteurs. #include // Pour la communication avec un peripherique #include // Pour utilisation de l'horloge RTC // // ! ================================================= ! // ! VARIABLES GLOBALES, CONSTANTES ET INITIALISATIONS ! // ! ================================================= ! // // Servo moteurs. // Servo sMoteurSejour; Servo sMoteurBureau; // // Pour l'horloge // RTC_DS1307 RTC; // Constante pour le module horloge // // Pour les calculs sur les dates et les heures // DateTime now; int iHeures = 0; int iMinutes = 0; int iMinutesAnciennes = 0; // // // ! ===== ! // ! SETUP ! // ! ===== ! // void setup() { Serial.begin(9600); delay(1000); Serial.println(" "); Serial.println(": ----------------------------------------- :"); Serial.println(": HORLOGE DES VOLETS DU SEJOUR ET DU BUREAU :"); Serial.println(": ----------------------------------------- :"); Serial.println(" "); Wire.begin(); RTC.begin(); // Ces lignes sont a utiliser uniquement pour les mises a l'heure //RTC.adjust(DateTime(__DATE__, __TIME__)); //Serial.println("L'horloge a ete remise a l'heure."); //Serial.println(" "); // // Initialisation des servo-moteurs. // sMoteurSejour.attach(15); // Broches du moteur de la commande du bureau sMoteurBureau.attach(14); // et de la commande du séjour. // } // // ! ==== ! // ! LOOP ! // ! ==== ! // void loop() { litLaDateEtLHeure(); if (iMinutes != iMinutesAnciennes) { Serial.print("Il est "); if (iHeures < 10) { Serial.print("0"); } Serial.print(iHeures); Serial.print(":"); if (iMinutes < 10) { Serial.print("0"); } Serial.println(iMinutes); iMinutesAnciennes = iMinutes; if ((iHeures == 7) && (iMinutes == 11)) { monteVoletBureau(); delay(5000); monteVoletSejour(); delay(60000); } if ((iHeures == 19) && (iMinutes == 55)) { baisseVoletBureau(); delay(5000); baisseVoletSejour(); delay(60000); } } } // // ! ========== ! // ! PROCEDURES ! // ! ========== ! // void baisseVoletBureau() { Serial.println("-----> Le volet du bureau est en train d'etre abaisse."); for (int position = 93; position >= 41; position--) { sMoteurBureau.write(position); delay(30); } delay(3000); for (int position = 41; position <= 93; position++) { sMoteurBureau.write(position); delay(30); } } void monteVoletBureau() { Serial.println("-----> Le volet du bureau est en train d'etre leve."); for (int position = 93; position <= 115; position++) { sMoteurBureau.write(position); delay(30); } delay(3000); for (int position = 115; position >= 93; position--) { sMoteurBureau.write(position); delay(30); } } void baisseVoletSejour() { Serial.println("-----> Le volet du sejour est en train d'etre abaisse."); for (int position = 93; position >= 84; position--) // 81 { sMoteurSejour.write(position); delay(30); } delay(3000); for (int position = 84; position <= 93; position++) { sMoteurSejour.write(position); delay(30); } } void monteVoletSejour() { Serial.println("-----> Le volet du sejour est en train d'etre leve."); for (int position = 93; position <= 105; position++) { sMoteurSejour.write(position); delay(30); } delay(3000); for (int position = 99; position >= 93; position--) { sMoteurSejour.write(position); delay(30); } } // // : ----------------- : // : Lit le module RTC : // : ----------------- : // void litLaDateEtLHeure() { now = RTC.now(); // On lit l'heure complete et on extrait iHeures = now.hour(); // l'heure, iMinutes = now.minute(); // les minutes, }