Components and supplies
Arduino Mega 2560
DS3231 clock module
Jumper wires (generic)
DHT11 Temperature & Humidity Sensor (4 pins)
SD card reader
Standard LCD - 16x2 White on Blue
Project description
Code
Smartclock Code
c_cpp
This is the code for the complete smartclock, version 3.2
1/*Smartclock version 2 and extensions by BasementResearch 2-first uploaded 9/17/18 (v 1.1) 3-New time setting system 9/18/18 (v 1.2) 4-New intro, states skipping, manual 9/19/18 (v 1.3) 5-Stopwatch, Clock can set am or pm 9/19/18 (v 1.4) 6-fixed major bug in date setting 9/20/18 (v 1.5) 7-fixed home scrolling bug 9/20/18 (v 1.6) 8-sd card functions added 9/21/18 (v 2.1) 9-fixed bug in stopwatch 9/22/18 (v 2.2) 10 11-added sd card save 9/26/18 (v 3.1) 12-fixed bug in date setting 9/26/18 (v 3.2) 13 14*/ 15 16/*LIBRARIES*/ 17#include <Keypad.h> 18#include <LiquidCrystal.h> 19#include <SimpleDHT.h> 20#include <Wire.h> 21#include <DS3231.h> 22#include <SD.h> 23/*END LIBS*/ 24 25/*LIB VARIABLES*/ 26 27 28//keypad 29const byte ROWS = 4; 30const byte COLS = 4; 31char hexaKeys[ROWS][COLS] = { 32 {'1','2','3','A'}, 33 {'4','5','6','B'}, 34 {'7','8','9','C'}, 35 {'*','0','#','D'} 36}; 37byte rowPins[ROWS] = {32, 31, 30, 29}; //connect to the row pinouts of the keypad 38byte colPins[COLS] = {28, 27, 26, 25}; 39Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 40 41//lcd screen 42LiquidCrystal lcd(35, 36, 37, 38, 39, 40); 43 44//thermometer 45int pinDHT11 = 49; 46SimpleDHT11 dht11; 47byte temperature = 0; 48byte humidity = 0; 49byte data[40] = {0}; 50 51//clock 52DS3231 clock; 53RTCDateTime dt; 54 55File myFile; 56 57/*END LIB VARIABLES*/ 58 59/*PROGRAM VARIABLES*/ 60 61int pageLimit = 4; 62int pageLimitN = 0; 63int nestPage = 0; 64int page = 0; 65 66int ht = 0; 67int ho = 0; 68int mt = 0; 69int mo = 0; 70int st = 0; 71int so = 0; 72int dT = 0; 73int dO = 0; 74int mnt = 0; 75int mno = 0; 76int ytT = 0; 77int yoO = 0; 78int hr = 0; 79int me = 0; 80int sd = 0; 81int md = 0; 82int v = 0; 83 84char* states[50] = {"Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky" 85 ,"Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina" 86 ,"North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"}; 87char stateChecks[50] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 88char* settingPages[] = {"Time & Date"}; 89int nestPageSettings = 0; 90int settingsPages = 0; 91 92/*END PROGRAM VARIABLES*/ 93 94 95/*CODE REPEAT FUNCTIONS*/ 96 97void reset(){ 98 lcd.clear(); 99 lcd.setCursor(0,0); 100} 101 102void loading(){ 103 reset(); 104 lcd.print("loading..."); 105 delay(1000); 106 reset(); 107} 108 109/*END CODE REPEAT FUNCTIONS*/ 110 111/*INTRO AND HOME FUNCTIONS*/ 112 113void lcdintro(){ 114 reset(); 115 lcd.print(" Welcome to"); 116 lcd.setCursor(0,1); 117 lcd.print("SmartClock V:3.2"); 118 delay(3000); 119 reset(); 120 delay(1000); 121 lcd.print("Press * to begin"); 122 lcd.setCursor(0,1); 123 lcd.print("or # for manual"); 124 int i = 0; 125 while(i != 1){ 126 char customKey = customKeypad.getKey(); 127 128 if(customKey){ 129 if(customKey == '*'){ 130 i = 1; 131 v = 0; 132 } 133 if(customKey == '#'){ 134 i = 1; 135 v = 1; 136 } 137 } 138 } 139 while(v == 1){ 140 reset(); 141 lcd.print("* means enter,"); 142 lcd.setCursor(0,1); 143 lcd.print("# means exit"); 144 delay(3000); 145 reset(); 146 lcd.print("A to go up,"); 147 lcd.setCursor(0,1); 148 lcd.print("B to go down"); 149 delay(3000); 150 reset(); 151 lcd.print("* means seen,"); 152 lcd.setCursor(0,1); 153 lcd.print("0 means not seen"); 154 delay(3000); 155 v = 0; 156 } 157 reset(); 158 lcd.print("loading..."); 159 lcd.setCursor(0,1); 160 for(int i = 0; i < 16; i ++){ 161 lcd.print("="); 162 delay(200); 163 } 164} 165 166void lcdSetpage(){ 167 int b = 0; 168 while(b == 0){ 169 char customKey = customKeypad.getKey(); 170 if(customKey){ 171 if(customKey == 'A'){ 172 if(page < pageLimit){ 173 page += 1; 174 }else{ 175 page = pageLimitN; 176 } 177 b = 1; 178 }else if(customKey == 'B'){ 179 if(page > pageLimitN){ 180 page --; 181 }else{ 182 page = pageLimit; 183 } 184 b = 1; 185 }else if(customKey == '*'){ 186 nestPage = 1; 187 b = 1; 188 } 189 } 190 } 191} 192 193void lcdhomepage(){ 194 page = 0; 195 nestPage = 0; 196 int a = 0; 197 while(a == 0){ 198 if(page == 0){ 199 if(nestPage == 1){ 200 lcdNesting0(); 201 } 202 reset(); 203 lcd.print("Temperature &"); 204 lcd.setCursor(0,1); 205 lcd.print("Humidity"); 206 } 207 if(page == 1){ 208 if(nestPage == 1){ 209 lcdNesting1(); 210 } 211 reset(); 212 lcd.print("Time"); 213 } 214 if(page == 2){ 215 if(nestPage == 1){ 216 lcdNesting2(); 217 } 218 reset(); 219 lcd.print("State Counter"); 220 } 221 if(page == 3){ 222 if(nestPage == 1){ 223 lcdNesting4(); 224 } 225 reset(); 226 lcd.print("Stopwatch"); 227 } 228 if(page == 4){ 229 if(nestPage == 1){ 230 lcdNesting3(); 231 } 232 reset(); 233 lcd.print("Settings"); 234 } 235 lcdSetpage(); 236 } 237 238} 239 240/*END INTRO AND HOME FUNCTIONS*/ 241 242/*TIMER FUNCTIONS*/ 243 244void lcdNesting1(){ 245 reset(); 246 lcd.print("loading..."); 247 delay(1000); 248 while(nestPage == 1){ 249 dt = clock.getDateTime(); 250 reset(); 251 lcd.print(clock.dateFormat("m/d/Y", dt)); 252 lcd.setCursor(0,1); 253 lcd.print(clock.dateFormat("h:i:s a", dt)); 254 for(int i = 0; i < 30000; i += 1){ 255 char customKey = customKeypad.getKey(); 256 if(customKey == '#'){ 257 nestPage = 0; 258 } 259 } 260 for(int i = 0; i < 30000; i += 1){ 261 char customKey = customKeypad.getKey(); 262 if(customKey == '#'){ 263 nestPage = 0; 264 } 265 } 266 for(int i = 0; i < 30000; i += 1){ 267 char customKey = customKeypad.getKey(); 268 if(customKey == '#'){ 269 nestPage = 0; 270 } 271 } 272 } 273} 274 275/*END TIMER FUNCTIONS*/ 276 277/*THERMOMETER FUNCTIONS*/ 278 279void lcdNesting0(){ 280 reset(); 281 lcd.print("loading..."); 282 delay(1000); 283 while(nestPage == 1){ 284 reset(); 285 if (dht11.read(pinDHT11, &temperature, &humidity, data)) { 286 reset(); 287 lcd.print("Read = Null"); 288 delay(500); 289 } 290 lcd.print((((int)temperature)*1.8+32)); 291 lcd.print(" *F "); 292 lcd.print((int)temperature); 293 lcd.print(" *C"); 294 lcd.setCursor(0,1); 295 lcd.print((int)humidity); 296 lcd.print(" humidity"); 297 for(int i = 0; i < 30000; i += 1){ 298 char customKey = customKeypad.getKey(); 299 if(customKey == '#'){ 300 nestPage = 0; 301 } 302 } 303 for(int i = 0; i < 30000; i += 1){ 304 char customKey = customKeypad.getKey(); 305 if(customKey == '#'){ 306 nestPage = 0; 307 } 308 }for(int i = 0; i < 30000; i += 1){ 309 char customKey = customKeypad.getKey(); 310 if(customKey == '#'){ 311 nestPage = 0; 312 } 313 } 314 } 315} 316 317/*END THERMOMETER FUNCTIONS*/ 318 319/*STATE CHECK FUNCTIONS*/ 320 321void lcdNesting2(){ 322 int InnerPage = 0; 323 reset(); 324 lcd.print("loading..."); 325 delay(1000); 326 reset(); 327 while(nestPage == 1){ 328 reset(); 329 lcd.print(states[InnerPage]); 330 if(stateChecks[InnerPage] == 0){ 331 lcd.setCursor(0,1); 332 lcd.print("Not seen"); 333 }if(stateChecks[InnerPage] == 1){ 334 lcd.setCursor(0,1); 335 lcd.print("Seen"); 336 } 337 for(int i = 0; i < 30000; i++){ 338 char customKey = customKeypad.getKey(); 339 if(customKey == 'A'){ 340 if(InnerPage < 49){ 341 InnerPage++; 342 }else{ 343 InnerPage = 0; 344 } 345 }if(customKey == 'B'){ 346 if(InnerPage > 0){ 347 InnerPage--; 348 }else{ 349 InnerPage = 49; 350 } 351 }if(customKey == '#'){ 352 nestPage = 0; 353 }if(customKey == '*'){ 354 stateChecks[InnerPage] = 1; 355 }if(customKey == '0'){ 356 stateChecks[InnerPage] = 0; 357 }if(customKey == 'C'){ 358 if((InnerPage+10) < 49){ 359 InnerPage+=10; 360 }else if((InnerPage+10) > 49 || (InnerPage+10) == 49){ 361 InnerPage = (InnerPage+10-49); 362 } 363 }if(customKey == 'D'){ 364 if((InnerPage-10) > 0){ 365 InnerPage-=10; 366 }else if((InnerPage-10) < 0 || (InnerPage-10) == 0){ 367 InnerPage = (InnerPage-10+49); 368 } 369 }if(customKey == '1'){ 370 reset(); 371 lcd.print("Attempting to"); 372 lcd.setCursor(0,1); 373 lcd.print("save data"); 374 delay(1000); 375 myFile = SD.open("myFile.txt", FILE_WRITE); 376 377 if(myFile){ 378 reset(); 379 lcd.print("In File..."); 380 delay(1000); 381 for(int i = 0; i < 49; i++){ 382 if(stateChecks[i] == 1){ 383 myFile.print(states[i]); 384 myFile.print(", "); 385 } 386 }dt = clock.getDateTime(); 387 myFile.println(clock.dateFormat("m/d/y, h:i:s a", dt)); 388 myFile.close(); 389 reset(); 390 lcd.print("Successfully"); 391 lcd.setCursor(0,1); 392 lcd.print("saved data"); 393 delay(1000); 394 }else if(!myFile){ 395 reset(); 396 lcd.print("Not successful"); 397 delay(1000); 398 } 399 } 400 } 401 } 402} 403 404 405/*END STATE CHECK FUNCTIONS*/ 406 407/*STOPWATCH FUNCTIONS*/ 408 409 410void lcdNesting4(){ 411 char customKey; 412 413 reset(); 414 loading(); 415 lcd.print("A to go,"); 416 lcd.setCursor(0,1); 417 lcd.print("B to stop"); 418 delay(2000); 419 reset(); 420 lcd.print(hr); 421 lcd.print(":"); 422 lcd.print(me); 423 lcd.print(":"); 424 lcd.print(sd); 425 lcd.print(":"); 426 lcd.print(md); 427 int xc = 0; 428 int bc = 1; 429 while(xc == 0){ 430 while(bc == 0){ 431 reset(); 432 lcd.print(hr); 433 lcd.print(":"); 434 lcd.print(me); 435 lcd.print(":"); 436 lcd.print(sd); 437 lcd.print(":"); 438 lcd.print(md); 439 delay(100); 440 md++; 441 if(md == 10){ 442 md = 0; 443 sd ++; 444 }if(sd == 60){ 445 sd = 0; 446 me ++; 447 }if(me == 60){ 448 me = 0; 449 hr++; 450 }if(hr == 99){ 451 hr = 0; 452 }customKey = customKeypad.getKey(); 453 if(customKey == 'B'){ 454 bc = 1; 455 } 456 } 457 customKey = customKeypad.getKey(); 458 if(customKey == 'A'){ 459 bc = 0; 460 }if(customKey == '#'){ 461 nestPage = 0; 462 xc = 1; 463 }if(customKey == 'C'){ 464 hr = 0; 465 me = 0; 466 sd = 0; 467 md = 0; 468 reset(); 469 lcd.print(hr); 470 lcd.print(":"); 471 lcd.print(me); 472 lcd.print(":"); 473 lcd.print(sd); 474 lcd.print(":"); 475 lcd.print(md); 476 } 477 478 } 479} 480 481/*END STOPWATCH FUNCTIONS*/ 482 483 484/*SETTINGS HOME FUNCTIONS*/ 485 486void lcdNesting3(){ 487 reset(); 488 lcd.print("Loading..."); 489 delay(1000); 490 reset(); 491 lcd.print("Choose setting"); 492 lcd.setCursor(0,1); 493 lcd.print("and click enter"); 494 delay(3000); 495 settingsPages = 0; 496 nestPageSettings = 0; 497 while(nestPage == 1){ 498 reset(); 499 lcd.print(settingPages[settingsPages]); 500 501 for(int i = 0; i < 30000; i++){ 502 char customKey = customKeypad.getKey(); 503 if(customKey == '#'){ 504 nestPage = 0; 505 }if(customKey == '*'){ 506 nestPageSettings = 1; 507 lcdNestingSettings0(); 508 } 509 } 510 } 511} 512 513/*END SETTINGS HOME FUNCTIONS*/ 514 515/*VOID SETUP AND LOOP*/ 516 517void setup() { 518 clock.begin(); 519 pinMode(53, OUTPUT); 520 lcd.begin(16, 2); 521 if(!SD.begin(53)){ 522 reset(); 523 lcd.print("sd not connected"); 524 delay(1000); 525 }else{ 526 myFile = SD.open("myFile.txt", FILE_WRITE); 527 myFile.println("Arduino Restarted!"); 528 myFile.println(" "); 529 myFile.close(); 530 } 531 lcdintro(); 532} 533 534void loop(){ 535 reset(); 536 lcdhomepage(); 537} 538 539/*END VOID SETUP AND LOOP*/ 540 541 542/*TIME SETTINGS*/ 543 544 545void lcdNestingSettings0(){ 546 reset(); 547 lcd.print("Push button for"); 548 lcd.setCursor(0,1); 549 lcd.print("hour (tens side)"); 550 int g = 0; 551 while(g == 0){ 552 char customKey = customKeypad.getKey(); 553 if(customKey == '1' || customKey == '0' || customKey == '2'){ 554 if(customKey == '1'){ 555 ht = 1; 556 }else if(customKey == '0'){ 557 ht = 0; 558 }else if(customKey == '2'){ 559 ht = 2; 560 } 561 g = 1; 562 } 563 } 564 565 reset(); 566 lcd.print("Push button for"); 567 lcd.setCursor(0,1); 568 lcd.print("hour (ones side)"); 569 g = 0; 570 while(g == 0){ 571 char customKey = customKeypad.getKey(); 572 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 573 if(customKey == '1'){ 574 ho = 1; 575 }else if(customKey == '2'){ 576 ho = 2; 577 }else if(customKey == '0'){ 578 ho = 0; 579 }else if(customKey == '3'){ 580 ho = 3; 581 }else if(customKey == '4'){ 582 ho = 4; 583 }else if(customKey == '5'){ 584 ho = 5; 585 }else if(customKey == '6'){ 586 ho = 6; 587 }else if(customKey == '7'){ 588 ho = 7; 589 }else if(customKey == '8'){ 590 ho = 8; 591 }else if(customKey == '9'){ 592 ho = 9; 593 } 594 g = 1; 595} 596 597 } 598 599 reset(); 600 lcd.print("Push button for"); 601 lcd.setCursor(0,1); 602 lcd.print("min. (tens side)"); 603 g = 0; 604 while(g == 0){ 605 char customKey = customKeypad.getKey(); 606 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 607 if(customKey == '1'){ 608 mt = 1; 609 }else if(customKey == '2'){ 610 mt = 2; 611 }else if(customKey == '0'){ 612 mt = 0; 613 }else if(customKey == '3'){ 614 mt = 3; 615 }else if(customKey == '4'){ 616 mt = 4; 617 }else if(customKey == '5'){ 618 mt = 5; 619 }else if(customKey == '6'){ 620 mt = 6; 621 }else if(customKey == '7'){ 622 mt = 7; 623 }else if(customKey == '8'){ 624 mt = 8; 625 }else if(customKey == '9'){ 626 mt = 9; 627 } 628 g = 1; 629} 630 631 } 632 633 reset(); 634 lcd.print("Push button for"); 635 lcd.setCursor(0,1); 636 lcd.print("min. (ones side)"); 637 g = 0; 638 while(g == 0){ 639 char customKey = customKeypad.getKey(); 640 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 641 if(customKey == '1'){ 642 mo = 1; 643 }else if(customKey == '2'){ 644 mo = 2; 645 }else if(customKey == '0'){ 646 mo = 0; 647 }else if(customKey == '3'){ 648 mo = 3; 649 }else if(customKey == '4'){ 650 mo = 4; 651 }else if(customKey == '5'){ 652 mo = 5; 653 }else if(customKey == '6'){ 654 mo = 6; 655 }else if(customKey == '7'){ 656 mo = 7; 657 }else if(customKey == '8'){ 658 mo = 8; 659 }else if(customKey == '9'){ 660 mo = 9; 661 } 662 g = 1; 663} 664 665 } 666 667 reset(); 668 lcd.print("Push button for"); 669 lcd.setCursor(0,1); 670 lcd.print("sec. (tens side)"); 671 g = 0; 672 while(g == 0){ 673 char customKey = customKeypad.getKey(); 674 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 675 if(customKey == '1'){ 676 st = 1; 677 }else if(customKey == '2'){ 678 st = 2; 679 }else if(customKey == '0'){ 680 st = 0; 681 }else if(customKey == '3'){ 682 st = 3; 683 }else if(customKey == '4'){ 684 st = 4; 685 }else if(customKey == '5'){ 686 st = 5; 687 }else if(customKey == '6'){ 688 st = 6; 689 }else if(customKey == '7'){ 690 st = 7; 691 }else if(customKey == '8'){ 692 st = 8; 693 }else if(customKey == '9'){ 694 st = 9; 695 } 696 g = 1; 697} 698 699 } 700 701 reset(); 702 lcd.print("Push button for"); 703 lcd.setCursor(0,1); 704 lcd.print("sec. (ones side)"); 705 g = 0; 706 while(g == 0){ 707 char customKey = customKeypad.getKey(); 708 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 709 if(customKey == '1'){ 710 so = 1; 711 }else if(customKey == '2'){ 712 so = 2; 713 }else if(customKey == '0'){ 714 so = 0; 715 }else if(customKey == '3'){ 716 so = 3; 717 }else if(customKey == '4'){ 718 so = 4; 719 }else if(customKey == '5'){ 720 so = 5; 721 }else if(customKey == '6'){ 722 so = 6; 723 }else if(customKey == '7'){ 724 so = 7; 725 }else if(customKey == '8'){ 726 so = 8; 727 }else if(customKey == '9'){ 728 so = 9; 729 } 730 g = 1; 731} 732 733 } 734 735 reset(); 736 lcd.print("Push button for"); 737 lcd.setCursor(0,1); 738 lcd.print("y. (tens side)"); 739 g = 0; 740 while(g == 0){ 741 char customKey = customKeypad.getKey(); 742 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 743 if(customKey == '1'){ 744 ytT = 1; 745 }else if(customKey == '2'){ 746 ytT = 2; 747 }else if(customKey == '0'){ 748 ytT = 0; 749 }else if(customKey == '3'){ 750 ytT = 3; 751 }else if(customKey == '4'){ 752 ytT = 4; 753 }else if(customKey == '5'){ 754 ytT = 5; 755 }else if(customKey == '6'){ 756 ytT = 6; 757 }else if(customKey == '7'){ 758 ytT = 7; 759 }else if(customKey == '8'){ 760 ytT = 8; 761 }else if(customKey == '9'){ 762 ytT = 9; 763 } 764 g = 1; 765} 766 767 } 768 769 reset(); 770 lcd.print("Push button for"); 771 lcd.setCursor(0,1); 772 lcd.print("y. (ones side)"); 773 g = 0; 774 while(g == 0){ 775 char customKey = customKeypad.getKey(); 776 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 777 if(customKey == '1'){ 778 yoO = 1; 779 }else if(customKey == '2'){ 780 yoO = 2; 781 }else if(customKey == '0'){ 782 yoO = 0; 783 }else if(customKey == '3'){ 784 yoO = 3; 785 }else if(customKey == '4'){ 786 yoO = 4; 787 }else if(customKey == '5'){ 788 yoO = 5; 789 }else if(customKey == '6'){ 790 yoO = 6; 791 }else if(customKey == '7'){ 792 yoO = 7; 793 }else if(customKey == '8'){ 794 yoO = 8; 795 }else if(customKey == '9'){ 796 yoO = 9; 797 } 798 g = 1; 799} 800 801 } 802 803 reset(); 804 lcd.print("Push button for"); 805 lcd.setCursor(0,1); 806 lcd.print("m. (tens side)"); 807 g = 0; 808 while(g == 0){ 809 char customKey = customKeypad.getKey(); 810 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 811 if(customKey == '1'){ 812 mnt = 1; 813 }else if(customKey == '2'){ 814 mnt = 2; 815 }else if(customKey == '0'){ 816 mnt = 0; 817 }else if(customKey == '3'){ 818 mnt = 3; 819 }else if(customKey == '4'){ 820 mnt = 4; 821 }else if(customKey == '5'){ 822 mnt = 5; 823 }else if(customKey == '6'){ 824 mnt = 6; 825 }else if(customKey == '7'){ 826 mnt = 7; 827 }else if(customKey == '8'){ 828 mnt = 8; 829 }else if(customKey == '9'){ 830 mnt = 9; 831 } 832 g = 1; 833} 834 835 } 836 837 reset(); 838 lcd.print("Push button for"); 839 lcd.setCursor(0,1); 840 lcd.print("m. (ones side)"); 841 g = 0; 842 while(g == 0){ 843 char customKey = customKeypad.getKey(); 844 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 845 if(customKey == '1'){ 846 mno = 1; 847 }else if(customKey == '2'){ 848 mno = 2; 849 }else if(customKey == '0'){ 850 mno = 0; 851 }else if(customKey == '3'){ 852 mno = 3; 853 }else if(customKey == '4'){ 854 mno = 4; 855 }else if(customKey == '5'){ 856 mno = 5; 857 }else if(customKey == '6'){ 858 mno = 6; 859 }else if(customKey == '7'){ 860 mno = 7; 861 }else if(customKey == '8'){ 862 mno = 8; 863 }else if(customKey == '9'){ 864 mno = 9; 865 } 866 g = 1; 867} 868 869 } 870 871 reset(); 872 lcd.print("Push button for"); 873 lcd.setCursor(0,1); 874 lcd.print("days (tens side)"); 875 g = 0; 876 while(g == 0){ 877 char customKey = customKeypad.getKey(); 878 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 879 if(customKey == '1'){ 880 dT = 1; 881 }else if(customKey == '2'){ 882 dT = 2; 883 }else if(customKey == '0'){ 884 dT = 0; 885 }else if(customKey == '3'){ 886 dT = 3; 887 }else if(customKey == '4'){ 888 dT = 4; 889 }else if(customKey == '5'){ 890 dT = 5; 891 }else if(customKey == '6'){ 892 dT = 6; 893 }else if(customKey == '7'){ 894 dT = 7; 895 }else if(customKey == '8'){ 896 dT = 8; 897 }else if(customKey == '9'){ 898 dT = 9; 899 } 900 g = 1; 901} 902 903 } 904 905 reset(); 906 lcd.print("Push button for"); 907 lcd.setCursor(0,1); 908 lcd.print("days (ones side)"); 909 g = 0; 910 while(g == 0){ 911 char customKey = customKeypad.getKey(); 912 if(customKey != 'A' && customKey != 'B' && customKey != 'C' && customKey != 'D' && customKey != '#' && customKey != '*' && customKey){ 913 if(customKey == '1'){ 914 dO = 1; 915 }else if(customKey == '2'){ 916 dO = 2; 917 }else if(customKey == '0'){ 918 dO = 0; 919 }else if(customKey == '3'){ 920 dO = 3; 921 }else if(customKey == '4'){ 922 dO = 4; 923 }else if(customKey == '5'){ 924 dO = 5; 925 }else if(customKey == '6'){ 926 dO = 6; 927 }else if(customKey == '7'){ 928 dO = 7; 929 }else if(customKey == '8'){ 930 dO = 8; 931 }else if(customKey == '9'){ 932 dO = 9; 933 } 934 g = 1; 935} 936 937 } 938 reset(); 939 lcd.print("loading..."); 940 clock.setDateTime(((yoO+(ytT*10)-48)),(mno+(mnt*10)),(dO+(dT*10)),/*Date-Time**/(ho+(ht*10)),(mo+(mt*10)),(so+(st*10))); 941} 942 943/**END TIME SETTINGS*/
Comments
Only logged in users can leave comments
Bie
0 Followers
•0 Projects
Table of contents
Intro
2
0