{"id":1459,"date":"2021-10-26T11:11:36","date_gmt":"2021-10-26T16:11:36","guid":{"rendered":"http:\/\/ve2cuy.com\/420-1c4\/?page_id=1459"},"modified":"2025-03-03T08:36:52","modified_gmt":"2025-03-03T13:36:52","slug":"grove-rtc_ds1307","status":"publish","type":"page","link":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/grove-rtc_ds1307\/","title":{"rendered":"Grove &#8211; RTC_DS1307"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">R<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">eal <\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">T<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">ime <\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">C<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">lock &#8211;<\/mark> <a href=\"https:\/\/wiki.seeedstudio.com\/Grove-RTC\/\">DS1307<\/a> <br><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">ou l&rsquo;art de tenir le temps<\/mark><\/h1>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/45d-1024x768.jpg\" alt=\"\" class=\"wp-image-1464\" srcset=\"https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/45d-1024x768.jpg 1024w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/45d-300x225.jpg 300w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/45d-768x576.jpg 768w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/45d.jpg 1400w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-pale-pink-color has-text-color\">1 &#8211; Description<\/h2>\n\n\n\n<p>Ce module permet de pr\u00e9server, en temps r\u00e9el, le passage du temps (ann\u00e9e, mois, jour, heure, minute, seconde), gr\u00e2ce \u00e0 une pile, entre les mises sous tension de l&rsquo;Arduino.<\/p>\n\n\n\n<p>M\u00eame hors tension du Arduino, le module RTC continuera de tenir compte du temps qui passe&#8230;<\/p>\n\n\n\n<p>Il est pilot\u00e9 par une puce <a href=\"https:\/\/www.maximintegrated.com\/en\/products\/analog\/real-time-clocks\/DS1307.html\">DS1307<\/a> de la compagnie Maxim.<\/p>\n\n\n\n<p><a href=\"https:\/\/datasheets.maximintegrated.com\/en\/ds\/DS1307.pdf\">R\u00e9f\u00e9rence technique<\/a> de la DS1307.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"364\" src=\"http:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/1sVqkSje-HMFhf-H-QJp1-A.png\" alt=\"\" class=\"wp-image-1502\" style=\"width:405px;height:211px\" srcset=\"https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/1sVqkSje-HMFhf-H-QJp1-A.png 700w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/1sVqkSje-HMFhf-H-QJp1-A-300x156.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/figure>\n<\/div>\n\n\n<p><strong><span class=\"has-inline-color has-vivid-red-color\">R\u00e9f\u00e9rence<\/span><\/strong>: <a href=\"https:\/\/wiki.seeedstudio.com\/Grove-RTC\/\">Wiki Grove<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><br><span class=\"has-inline-color has-cyan-bluish-gray-color\">2 &#8211; Type de connexion:<\/span> <span class=\"has-inline-color has-vivid-green-cyan-color\">I2C<\/span><br><\/h2>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-red-color has-text-color\"><br>3 &#8211; Librairie \u00e0 installer<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"360\" height=\"305\" src=\"http:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/Capture-decran-le-2021-10-26-a-12.35.55.png\" alt=\"\" class=\"wp-image-1465\" srcset=\"https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/Capture-decran-le-2021-10-26-a-12.35.55.png 360w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/Capture-decran-le-2021-10-26-a-12.35.55-300x254.png 300w\" sizes=\"auto, (max-width: 360px) 100vw, 360px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Voici la d\u00e9pendance \u00e0 utiliser sous PlatformIO:<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lib_deps = seeed-studio\/Grove - RTC DS1307@^1.0.0<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-purple-color has-text-color\"><br>4 &#8211; Exemples d&rsquo;utilisation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-luminous-vivid-amber-color has-text-color\"><br>4.1 &#8211;  Renseigner le temps, puis le lire &#8211; version de d\u00e9part<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;Wire.h>\n#include \"DS1307.h\"\n#include \"Streaming.h\"\n\nDS1307 horloge; \/\/ D\u00e9finir un objet de type DS1307\n\nvoid setup()\n{\n  Serial.begin(9600);\n  Serial &lt;&lt; \"Debut du programme ...\\n\"; \n\n  horloge.begin();\n\n  \/\/ 1 - Renseigner la date et l'heure\n  \/\/ Note: \u00c0 ne faire qu'une seule fois puis,\n  \/\/ placer les lignes suivantes en commentaires\n  horloge.fillByYMD(2025,02,26);\n  horloge.fillByHMS(11,54,30);\n  horloge.fillDayOfWeek(TUE);\n\n  \/\/ 2 - \u00c9crire le temps dans la puce RTC \n  horloge.setTime();\n\n  \/\/ 3 - Lire le temps du RTC\n  horloge.getTime();\n  \n  \/\/ 4 - Afficher l'heure\n  Serial &lt;&lt; \"Il est \" &lt;&lt; horloge.hour &lt;&lt; \":\" &lt;&lt; horloge.minute &lt;&lt; \":\" &lt;&lt; horloge.second &lt;&lt; endl;\n  \n} \/\/ setup\n\nvoid loop() {} \/\/ loop<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading has-vivid-cyan-blue-color has-text-color\"><br>4.2 &#8211; Afficher le temps courant &#8211; version 1 (Inutilement longue)<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;Wire.h>\n#include \"DS1307.h\"\n#include \"Streaming.h\"\n\nDS1307 clock; \/\/ D\u00e9finir un objet de type DS1307\n\nvoid setup()\n{\n  Serial.begin(9600);\n  Serial &lt;&lt; \"Debut du programme ...\\n\"; \n\tclock.begin();\n  \/*\n\tclock.fillByYMD(2021,10,26);\n\tclock.fillByHMS(11,54,30);\n\tclock.fillDayOfWeek(TUE); \n\tclock.setTime(); \/\/\u00c9crire le temps dans la puce RTC\n  *\/\n} \/\/ setup\n\nvoid loop()\n{\n  AfficherLeTemps();\n} \/\/ loop\n\n\n\/\/ =============================================================\n\/\/ Fonction: Afficher le temps dans la console s\u00e9rie - version 1\n\/\/ =============================================================\nvoid AfficherLeTemps()\n{\n\tclock.getTime();\n\tSerial.print(clock.hour, DEC);\n\tSerial.print(\":\");\n\tSerial.print(clock.minute, DEC);\n\tSerial.print(\":\");\n\tSerial.print(clock.second, DEC);\n\tSerial.print(\"\t\");\n\tSerial.print(clock.month, DEC);\n\tSerial.print(\"\/\");\n\tSerial.print(clock.dayOfMonth, DEC);\n\tSerial.print(\"\/\");\n\tSerial.print(clock.year+2000, DEC);\n\tSerial.print(\" \");\n\n  String nomDuJour;\n\tswitch (clock.dayOfWeek)\n\t{\n\t\tcase MON:\n      nomDuJour = \"Lundi\";\n\t\t  break;\n\t\tcase TUE:\n\t\t  nomDuJour = \"Mardi\";\n\t\t  break;\n\t\tcase WED:\n\t\t  nomDuJour = \"Mercredi\";\n\t\t  break;\n\t\tcase THU:\n\t\t  nomDuJour = \"Jeudi\";\n\t\t  break;\n\t\tcase FRI:\n\t\t  nomDuJour = \"Vendredi\";\n\t\t  break;\n\t\tcase SAT:\n\t\t  nomDuJour = \"Samedi\";\n\t\t  break;\n\t\tcase SUN:\n\t\t  nomDuJour = \"Dimanche\";\n\t\t  break;\n\t}\n\tSerial &lt;&lt; nomDuJour &lt;&lt; \" le \" &lt;&lt; clock.dayOfMonth &lt;&lt; endl;\n  delay(1000);\n}\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading has-vivid-green-cyan-color has-text-color\"><br>4.3 &#8211; Afficher le temps courant &#8211; version 2 (Beaucoup mieux)<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;Wire.h>\n#include \"DS1307.h\"\n#include \"Streaming.h\"\n\nDS1307 clock; \/\/ D\u00e9finir un objet de type DS1307\n\/\/ Variable utilis\u00e9e par sprintf()\nchar chaine[80];\nchar* NomDesJours[] = {\"\", \"Lundi\", \"Mardi\", \"Mercredi\", \"Jeudi\", \"Vendredi\", \"Samedi\", \"Dimanche\"};\n\nvoid setup()\n{\n  Serial.begin(9600);\n  Serial &lt;&lt; \"Debut du programme ...\\n\"; \n\tclock.begin();\n  \/*\n\tclock.fillByYMD(2021,10,26);\n\tclock.fillByHMS(11,54,30);\n\tclock.fillDayOfWeek(TUE); \n\tclock.setTime(); \/\/\u00c9crire le temps dans la puce RTC\n  *\/\n} \/\/ setup\n\nvoid loop()\n{\n  AfficherLeTemps();\n} \/\/ loop\n\n\n\/\/ =============================================================\n\/\/ Fonction: Afficher le temps dans la console s\u00e9rie - version 2\n\/\/ =============================================================\nvoid AfficherLeTemps()\n{\n  clock.getTime();\n  \/\/ Remplacer les Serial.print par un sprintf()\n  sprintf(chaine, \"%02d:%02d:%02d  %02d\/%02d\/%02d,  \",\n    clock.hour, clock.minute, clock.second, \n    clock.month, clock.dayOfMonth, clock.year+2000\n  );\n  Serial &lt;&lt; chaine;\n\n  \/\/ Remplacer le switch par un tableau de char*\n  Serial &lt;&lt; NomDesJours[clock.dayOfWeek] &lt;&lt; \" le \" &lt;&lt; clock.dayOfMonth &lt;&lt; endl;\n  delay(1000);\n}\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading has-luminous-vivid-orange-color has-text-color\"><br>4.4 &#8211; Afficher le temps courant &#8211; version optimis\u00e9e (Qui dit mieux?)<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;Wire.h>\n#include \"DS1307.h\"\n#include \"Streaming.h\"\n\nDS1307 clock; \/\/ D\u00e9finir un objet de type DS1307\n\n\/\/ Variable utilis\u00e9e par sprintf()\nchar chaine[80];\n\nchar* NomDesJours[] = {\"\", \"Lundi\", \"Mardi\", \"Mercredi\", \"Jeudi\", \"Vendredi\", \"Samedi\", \"Dimanche\"};\n\nvoid setup()\n{\n  Serial.begin(9600);\n  Serial &lt;&lt; \"Debut du programme ...\\n\"; \n\tclock.begin();\n  \/*\n\tclock.fillByYMD(2021,10,26);\n\tclock.fillByHMS(11,54,30);\n\tclock.fillDayOfWeek(TUE); \n\tclock.setTime(); \/\/\u00c9crire le temps dans la puce RTC\n  *\/\n} \/\/ setup\n\nvoid loop()\n{\n  Serial &lt;&lt; AfficherLeTemps() &lt;&lt; endl;\n  delay(1000);\n} \/\/ loop\n\n\n\/\/ =============================================================\n\/\/ Fonction: Forme une chaine repr\u00e9sentant le temps courant - V3\n\/\/ Retour:   Un pointeur vers une chaine de caract\u00e8res d\u00e9crivant\n\/\/           le temps courant.\n\/\/ =============================================================\nchar* AfficherLeTemps()\n{\n  clock.getTime();\n  sprintf(chaine, \"%02d:%02d:%02d  %02d\/%02d\/%02d,  %s le %02d\",\n    clock.hour, clock.minute, clock.second, \n    clock.month, clock.dayOfMonth, clock.year+2000,\n    NomDesJours[clock.dayOfWeek], clock.dayOfMonth\n  );\n\n  return chaine;\n\n} \/\/ AfficherLeTemps\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5 &#8211; <span class=\"has-inline-color has-vivid-red-color\">Laboratoire (30 minutes)<\/span> &#8211; Afficher l&rsquo;heure et la date<\/h2>\n\n\n\n<p>\u00c9crire un programme qui affiche l&rsquo;heure et la date, \u00e0 chaque seconde, \u00e0 la position 0,0 du moniteur, en utilisant le format suivant:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"491\" height=\"39\" src=\"https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2025\/02\/Capture-decran-le-2025-02-26-a-09.12.51.png\" alt=\"\" class=\"wp-image-3041\" style=\"width:655px;height:auto\" srcset=\"https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2025\/02\/Capture-decran-le-2025-02-26-a-09.12.51.png 491w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2025\/02\/Capture-decran-le-2025-02-26-a-09.12.51-300x24.png 300w\" sizes=\"auto, (max-width: 491px) 100vw, 491px\" \/><\/figure>\n<\/div>\n\n\n<p>Utiliser des s\u00e9quences ANSI pour la couleur et le positionnement.<\/p>\n\n\n\n<p>Il faut actualiser l&rsquo;affichage \u00e0 chaque seconde.<\/p>\n\n\n\n<p>Id\u00e9alement, utiliser une m\u00e9thode non bloquante pour l&rsquo;affichage.<\/p>\n\n\n\n<p>Rappel<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include \"ANSI.h\"\nANSI ansi(&amp;Serial);\n#define ANSI_ROUGE          \"\\033[31m\"\n#define ANSI_BLEU           \"\\033[34m\"\n#define ANSI_BLANC          \"\\033[0m\"\n#define CURSEUR_OFF         \"\\033[?25l\"<\/pre>\n\n\n\n<p>\ud83d\udc49 Il faut renseigner un tableau pour le nom des jours et un pour le nom des mois.<\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">NOTE<\/mark><\/strong>: En C++, il n&rsquo;est pas recommand\u00e9 de d\u00e9finir un tableau de chaines de caract\u00e8res en objet muable.  Il est pr\u00e9f\u00e9rable de le d\u00e9finir ansi:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">const char* tableau[] = {...}<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5.1 &#8211; <span class=\"has-inline-color has-vivid-red-color\">Laboratoire (30 minutes)<\/span> &#8211; Afficher l&rsquo;heure sur 4-Digit<\/h2>\n\n\n\n<p>\u00c0 partir:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>du module 4-Digit sur GPIO 8 et 9,<\/li>\n\n\n\n<li>et du RTC DS1307 sur I2C,<\/li>\n<\/ul>\n\n\n\n<p>\u00e9crire un programme qui affiche l&rsquo;heure en temps r\u00e9el (HH:MM) sur le module 4-Digit.<\/p>\n\n\n\n<p>Le symbole \u00ab\u00a0:\u00a0\u00bb du 4-Digit doit clignoter avec les secondes qui passent.<\/p>\n\n\n\n<p>Id\u00e9alement, utiliser une m\u00e9thode non bloquante pour le clignotement.<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Astuces<\/strong>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">float heureDecimale = horloge.hour + float(horloge.minute) \/ 100 ;  \/\/ Convertir les minutes en d\u00e9cimales et + heures.\nint   heureInt      = horloge.hour * 100 + horloge.minute;          \/\/ Former un grand int avec les hr+min\n\n\u00c0 chaque 500 ms, permuter l'affichage entre heureDecimale et heureInt:\n   \n  displayNum(heureDecimale,2);\n  displayNum(heureInt);\n\n\nG\u00e9rer la permutation avec une variable de type boolean.\nPermuter la valeur de la variable boolean de cette fa\u00e7on:  tick ^= true;\n<\/pre>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Autres astuces fonctionnelles avec Wokwi:<\/strong><\/p>\n\n\n\n<p>Utilisation des m\u00e9thodes <strong><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">display()<\/mark><\/em><\/strong> et <em><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">point()<\/mark><\/strong><\/em> de la classe TM1637<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  \/\/ Cette technique fonctionnera sur Wokwi ainsi qu'avec la librairie standard de la TM1637\n  affichage.point(true); \/\/ Allumer le : du 4 digit, au prochain affichage\n  affichage.display(0, horloge.hour \/ 10);  \/\/ Afficher sur le nombre de gauche, la dizaine de l'heure\n  affichage.display(1, horloge.hour % 10);  \/\/ Afficher sur le nombre de gauche+1, l'unit\u00e9 de l'heure\n  affichage.point(false); \/\/ \u00c9teindre le : du 4 digit, au prochain affichage\n<\/pre>\n\n\n<div class=\"wp-block-ub-expand ub-expand \" id=\"ub-expand-4b726cc8-98f5-4a3d-a367-121b2832625a\">\n<div class=\"ub-expand-portion ub-expand-partial\" id=\"ub-expand-portion-\"><a class=\"ub-expand-toggle-button\" role=\"button\" aria-expanded=\"false\" aria-controls=\"ub-expand-full-4b726cc8-98f5-4a3d-a367-121b2832625a\" tabindex=\"0\"><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">Afficher la solution<\/span><\/strong><\/a><\/div>\n\n<div class=\"ub-expand-portion ub-expand-full ub-hide\" id=\"ub-expand-portion-\">\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/*\n    Solution du laboratoire: Afficher l'heure sur 4-Digit \n\n    Auteur: Alain Boudreault, aka VE2CUY \n    Date:   2021.10.26\n\n    Description:  Afficher l'heure en temps r\u00e9el en\n                  utilisant le format HH:MM.\n\n                  Le s\u00e9parateur ':' clignote \u00e0 la fr\u00e9quence de 500 ms.\n*\/\n\n#include &lt;Wire.h>\n#include \"DS1307.h\"\n#include \"Streaming.h\"\n#include \"TM1637V2.h\"\n\nDS1307 horloge; \/\/ D\u00e9finir un objet de type DS1307\n\n\/\/ #define SET_TIME\n\n#define CLK 2  \/\/GPIO pour la TM1637V2\n#define DIO 3\n#define DEMI_SECONDE 500\nTM1637V2 affichage(CLK, DIO);\nboolean tick = false;\n\nvoid setup()\n{\n  Serial.begin(9600);\n  Serial &lt;&lt; \"Debut du programme ...\\n\"; \n  horloge.begin();\n  affichage.init();\n  affichage.clearDisplay();\n  affichage.set(ECRAN_FORT);\n\n  #ifdef SET_TIME\n    horloge.fillByYMD(2021,10,26);\n    horloge.fillByHMS(13,54,00);\n    horloge.fillDayOfWeek(TUE);\n    horloge.setTime();\n  #endif\n} \/\/ setup\n\nvoid loop() {\n  horloge.getTime();\n  float heureDecimale = horloge.hour + float(horloge.minute) \/ 100 ;  \/\/ Pour affichage avec ':'\n  int   heureInt      = horloge.hour * 100 + horloge.minute;          \/\/ Pour affichage sans ':'\n\n  \/\/ En fonction de la valeur de 'tick' afficher l'heure int ou float \u00e0 2 dec.\n  affichage.displayNum(tick ? heureInt : heureDecimale, tick ? 0 : 2);\n  tick ^= true;  \/\/ Inverser la valeur de la variable boolean\n\n  \/\/ Afficher une trace de l'heure\n  Serial &lt;&lt; \"Il est \" &lt;&lt; horloge.hour &lt;&lt; \":\" &lt;&lt; horloge.minute &lt;&lt; \":\" &lt;&lt; horloge.second &lt;&lt; endl;\n  delay(DEMI_SECONDE);\n\n} \/\/ loop<\/pre>\n\n<a class=\"ub-expand-toggle-button\" role=\"button\" aria-expanded=\"false\" aria-controls=\"ub-expand-full-4b726cc8-98f5-4a3d-a367-121b2832625a\" tabindex=\"0\">Masquer la solution<\/a><\/div>\n<\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"370\" height=\"193\" src=\"http:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2022\/11\/4-digit-lib.png\" alt=\"\" class=\"wp-image-2452\" srcset=\"https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2022\/11\/4-digit-lib.png 370w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2022\/11\/4-digit-lib-300x156.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5.2 &#8211; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Laboratoire<\/mark> (60 minutes)<\/h2>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">NOTE<\/mark><\/strong>: Pour la session H25 &#8211; Ce labo permet d&rsquo;ajouter deux (2) points bonis \u00e0 la grille d&rsquo;\u00e9valuation du cours.<\/p>\n\n\n\n<p>Combiner les laboratoires 5 et 5.1 en un seul programme, avec affichages non bloquants, et y ajouter la fonctionnalit\u00e9 suivante:<\/p>\n\n\n\n<p>Faire d\u00e9filer le message;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">Nous sommes le 8 Fevrier, 21:53:27<\/mark><\/strong><\/em>\n<ul class=\"wp-block-list\">\n<li>Le texte du LCD est actualis\u00e9 \u00e0 chaque 7 secondes<\/li>\n\n\n\n<li>Le d\u00e9filement est de 300ms<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>sur l&rsquo;\u00e9cran LCD.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"720\" style=\"aspect-ratio: 1280 \/ 720;\" width=\"1280\" controls src=\"https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2025\/02\/Horloge.mov\"><\/video><\/figure>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">NOTE<\/mark><\/strong>: La librairie propose une m\u00e9thode pour faire d\u00e9filer du texte \u00e0 l&rsquo;\u00e9cran.  Faites vos recherches.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Une <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">LED<\/mark><\/strong>, connect\u00e9e sur D2 doit s&rsquo;allumer quand on enfonce le <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">bouton<\/mark><\/strong> connect\u00e9 sur D3 et doit rester aller tant que le bouton est ON.<\/li>\n<\/ul>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">NOTE IMPORTANTE<\/mark><\/strong>: Les affichages, moniteur, LCD et 4Digit ne doivent pas bloquer le programme principal.  La LED doit r\u00e9pondre instantan\u00e9ment au bouton.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h6 class=\"wp-block-heading has-text-align-right has-cyan-bluish-gray-color has-text-color\">Document r\u00e9dig\u00e9 par Alain Boudreault, aka VE2CUY &#8211; version 2025.02.26.01<\/h6>\n","protected":false},"excerpt":{"rendered":"<p>Real Time Clock &#8211; DS1307 ou l&rsquo;art de tenir le temps 1 &#8211; Description Ce module permet de pr\u00e9server, en temps r\u00e9el, le passage du temps (ann\u00e9e, mois, jour, heure, minute, seconde), gr\u00e2ce \u00e0 une pile, entre les mises sous tension de l&rsquo;Arduino. M\u00eame hors tension du Arduino, le module RTC continuera de tenir compte [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ub_ctt_via":"","footnotes":""},"class_list":["post-1459","page","type-page","status-publish","hentry"],"featured_image_src":null,"_links":{"self":[{"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/pages\/1459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/comments?post=1459"}],"version-history":[{"count":59,"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/pages\/1459\/revisions"}],"predecessor-version":[{"id":3088,"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/pages\/1459\/revisions\/3088"}],"wp:attachment":[{"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/media?parent=1459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}