{"id":280,"date":"2021-01-25T00:02:05","date_gmt":"2021-01-24T23:02:05","guid":{"rendered":"https:\/\/snurps.fr\/?p=280"},"modified":"2021-02-01T22:27:24","modified_gmt":"2021-02-01T21:27:24","slug":"une-horloge-arduino-sans-module-rtc-partie-2","status":"publish","type":"post","link":"https:\/\/snurps.fr\/?p=280","title":{"rendered":"UNE HORLOGE ARDUINO SANS MODULE RTC (PARTIE 2)"},"content":{"rendered":"\n<p>Suite de nos articles permettant de se confectionner une petite horloge a &nbsp;base d arduino sans module RTC<\/p>\n\n\n\n<p>Cette fois ci, j\u2019ai cherch\u00e9 a augmenter la lisibilit\u00e9 de l\u2019horloge, en utilisant tout l espace disponible.<\/p>\n\n\n\n<p>Pour se faire, dans le code ci dessous, on d\u00e9crit (ligne 23 a 132) des morceaux de lettres, qu\u2019on utilise ensuite (ligne 154 a 163) pour cr\u00e9er les chiffres de 0 a 9\u2026 ensuite, on imbrique tout ca dans le code d\u2019article pr\u00e9c\u00e9dant,<\/p>\n\n\n\n<p>ET VOILA !<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"theme:solarized-dark font:liberation-mono toolbar:1 show-lang:2 lang:arduino decode:true \">#include &lt;LiquidCrystal.h&gt;\n#include \"LCDKeypad.h\"\n\n\/\/LiquidCrystal lcd(8, 9, 4, 5, 6, 7);\n\/\/#define DAYS 0\n#define HOURS \n#define MINUTES 2\n#define SECONDS 3\n#define SECONDS 3\n#define secdisp 4\n\n\/\/ The LCD screen\n\nLCDKeypad lcd;\n\n\/\/ The time model\n\n\/\/unsigned int days = 0;\n\nunsigned int hours = 0;\n\nunsigned int minutes = 0;\n\nunsigned int seconds = 0;\n\nunsigned int setting = 0;\n\n\/\/ the 8 arrays that form each segment of the custom numbers\n\nbyte A[8] = {\n\nB00111,\n\nB01111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111\n\n};\n\nbyte B[8] = {\n\nB11111,\n\nB11111,\n\nB11111,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000\n\n};\n\nbyte C[8] = {\n\nB11100,\n\nB11110,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111\n\n};\n\nbyte D[8] = {\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB01111,\n\nB00111\n\n};\n\nbyte E[8] = {\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB11111,\n\nB11111,\n\nB11111\n\n};\n\nbyte F[8] = {\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11111,\n\nB11110,\n\nB11100\n\n};\n\nbyte G[8] = {\n\nB11111,\n\nB11111,\n\nB11111,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB11111,\n\nB11111\n\n};\n\nbyte H[8] = {\n\nB11111,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB11111,\n\nB11111,\n\nB11111\n\n};\n\nbyte I[8] = {\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00011,\n\nB00011,\n\nB00011\n\n};\n\nbyte J[8] = {\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB00000,\n\nB11000,\n\nB11000,\n\nB11000\n\n};\n\nint x;\n\nvoid fontHelper(byte a, byte b, byte c, byte d, byte e, byte f)\n\n{\n\n   lcd.setCursor(x,0);\n\n   lcd.write(a);\n\n   lcd.write(b);\n\n   lcd.write(c);\n\n   lcd.setCursor(x,1);\n\n   lcd.write(d);\n\n   lcd.write(e);\n\n   lcd.write(f);\n\n}\n\nvoid custom(byte digit)\n\n{\n\n switch (digit)\n\n {\n\n   case 0: fontHelper(0,1,2,3,4,5); break;\n\n   case 1: fontHelper(1,2,32,32,255,32); break;\n\n   case 2: fontHelper(6,6,2,3,7,7); break;\n\n   case 3: fontHelper(6,6,2,7,7,5); break;\n\n   case 4: fontHelper(3,4,2,32,32,255); break;\n\n   case 5: fontHelper(255,6,6,7,7,5); break;\n\n   case 6: fontHelper(0,6,6,3,7,5); break;\n\n   case 7: fontHelper(1,1,2,32,0,32); break;\n\n   case 8: fontHelper(0,6,2,3,7,5); break;\n\n   case 9: fontHelper(0,6,2,32,32,255); break;\n\n   }\n\n}\n\nvoid setup() {\n\n\/\/ Set up the LCD\u2019s number of columns and rows:\n\nlcd.begin(16,2);\n\n\/\/ Set the cursor at the begining of the first row\n\nlcd.setCursor(0,0);\n\n\/\/ Print a text in the first row\n\n\/\/lcd.print(\u00ab Setting: Days \u00ab );\n\nSerial.begin(9600);\n\n \/\/ assignes each segment a write number\n\n lcd.createChar(0,A);\n\n lcd.createChar(1,B);\n\n lcd.createChar(2,C);\n\n lcd.createChar(3,D);\n\n lcd.createChar(4,E);\n\n lcd.createChar(5,F);\n\n lcd.createChar(6,G);\n\n lcd.createChar(7,H);\n\n \/\/lcd.createChar(215,I);\n\n\/\/  lcd.createChar(251,J);\n\n \/\/ sets the LCD\u2019s rows and colums:\n\n lcd.begin(16, 2);\n\n}\n\nvoid loop() {\n\n\/\/ Increase the time model by one second\n\nincTime();\n\n\/\/ Print the time on the LCD\n\nprintTime();\n\n\/\/ Listen for buttons for 1 second\n\nbuttonListen();\n\n}\n\nvoid buttonListen() {\n\n\/\/ Read the buttons five times in a second\n\nfor (int i = 0; i &lt; 5; i++) {\n\n\/\/ Read the buttons value\n\nint button = lcd.button();\n\nswitch (button) {\n\n\/\/ Right button was pushed\n\ncase KEYPAD_RIGHT:\n\nsetting++;\n\nbreak;\n\n\/\/ Left button was pushed\n\ncase KEYPAD_LEFT:\n\nsetting\u2013;\n\nbreak;\n\n\/\/ Up button was pushed\n\ncase KEYPAD_UP:\n\nswitch (setting) {\n\n\/\/case DAYS:\n\n\/\/days++;\n\n\/\/break;\n\ncase HOURS:\n\nhours++;\n\nbreak;\n\ncase MINUTES:\n\nminutes++;\n\n\/\/break;\n\n\/\/case SECONDS:\n\n\/\/seconds++;\n\n}\n\nbreak;\n\n\/\/ Down button was pushed\n\ncase KEYPAD_DOWN:\n\nswitch (setting) {\n\n\/\/case DAYS:\n\n\/\/days\u2013;\n\n\/\/if (days == -1) days = 99;\n\n\/\/break;\n\ncase HOURS:\n\nhours\u2013;\n\nif (hours == -1) hours = 23;\n\nbreak;\n\ncase MINUTES:\n\nminutes\u2013;\n\nif (minutes == -1) minutes = 59;\n\n\/\/break;\n\n\/\/case SECONDS:\n\n\/\/seconds\u2013;\n\n\/\/if (seconds == -1) seconds = 59;\n\n}\n\n}\n\nsetting %= 3;\n\nprintSetting();\n\n\/\/days %= 100;\n\nhours %= 24;\n\nminutes %= 60;\n\nseconds %= 60;\n\nprintTime();\n\n\/\/ Wait one fifth of a second to complete\n\nwhile(millis() % 200 != 0);\n\n}\n\n}\n\n\/\/ Print the current setting\n\nvoid printSetting() {\n\nlcd.setCursor(9,0);\n\nswitch (setting) {\n\n\/\/case DAYS:\n\n\/\/lcd.print(\u00ab Days \u00ab );\n\n\/\/break;\n\n\/\/case HOURS:\n\n\/\/lcd.print(\u00ab Hours \u00ab );\n\n\/\/break;\n\n\/\/case MINUTES:\n\n\/\/lcd.print(\u00ab Minutes \u00bb);\n\n\/\/break;\n\n\/\/case SECONDS:\n\n\/\/lcd.print(\u00ab Seconds \u00bb);\n\n}\n\n}\n\n\/\/ Increase the time model by one second\n\nvoid incTime() {\n\n\/\/ Increase seconds\n\nseconds++;\n\nif (seconds == 60) {\n\n\/\/ Reset seconds\n\nseconds = 0;\n\n\/\/ Increase minutes\n\nminutes++;\n\nif (minutes == 60) {\n\n\/\/ Reset minutes\n\nminutes = 0;\n\n\/\/ Increase hours\n\nhours++;\n\nif (hours == 24) {\n\n\/\/ Reset hours\n\nhours = 0;\n\n\/\/ Increase days\n\n\/\/days++;\n\n}\n\n}\n\n}\n\n}\n\n\/\/ Print the time on the LCD\n\nvoid printTime() {\n\n\/\/int outputValue = analogRead(analogInPin);\n\nint outputmin = minutes;\n\nint outputhour = hours;\n\n \/\/Serial.print(\u00ab output = \u00ab );\n\n\/\/Serial.println(outputValue);\n\n byte thousands = outputhour \/10;\n\n outputhour %= 10;\n\n byte hundreds = outputhour ;\n\n byte tens = outputmin \/10;\n\n byte ones = outputmin % 10;\n\n x = 0;\n\n custom(thousands);\n\n \/\/delay(500);\n\n x = x+4;\n\n custom(hundreds);\n\n \/\/delay(500);\n\n\/\/ Set the cursor at the begining of the second row\n\n\/\/lcd.setCursor(0,1);\n\n\/\/char time[17];\n\n\/\/sprintf(time, \u00ab %02i days %02i:%02i:%02i \u00bb, days, hours, minutes, seconds);\n\nx = x+3;\n\nif(seconds % 2 == 0) {\n\n\/\/sprintf(time, \u00ab %02i:%02i \u00bb, hours, minutes);\n\n\/\/}\n\n\/\/fontHelper(4,32,32,1,32,32);\n\nfontHelper(165,32,32,165,32,32);\n\n}\n\nelse {\n\nfontHelper(32,32,32,32,32,32);\n\n\/\/sprintf(time, \u00ab %02i %02i \u00bb, hours, minutes);\n\n}\n\n\/\/lcd.print(time);\n\n x = x+2;\n\n custom(tens);\n\n \/\/delay(500);\n\n x = x+4;\n\n custom(ones);\n\n \/\/delay(500);\n\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Suite de nos articles permettant de se confectionner une petite horloge a &nbsp;base d arduino sans module RTC Cette fois ci, j\u2019ai cherch\u00e9 a augmenter la lisibilit\u00e9 de l\u2019horloge, en utilisant tout l espace disponible. Pour se faire, dans le code ci dessous, on d\u00e9crit (ligne 23 a 132) des morceaux de lettres, qu\u2019on utilise [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":275,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[27],"tags":[],"class_list":["post-280","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","post-wrapper","thrv_wrapper"],"_links":{"self":[{"href":"https:\/\/snurps.fr\/index.php?rest_route=\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/snurps.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/snurps.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/snurps.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/snurps.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=280"}],"version-history":[{"count":4,"href":"https:\/\/snurps.fr\/index.php?rest_route=\/wp\/v2\/posts\/280\/revisions"}],"predecessor-version":[{"id":324,"href":"https:\/\/snurps.fr\/index.php?rest_route=\/wp\/v2\/posts\/280\/revisions\/324"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/snurps.fr\/index.php?rest_route=\/wp\/v2\/media\/275"}],"wp:attachment":[{"href":"https:\/\/snurps.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/snurps.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/snurps.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}