만든지는 좀 되긴 했지만 이런저런 사정에 의해 이제서야 올리게 된다.
Arduino에 대해 재미를 붙이고 있고 또 이것저것 해보기 좋고해서…
점점 탄력이 붙는것 같은데… 시간이 잘 안난다.
앞서 Arduino와 RTC를 이용해서 시계 테스트를 해본것에 힘입어 실제 사용할 수 있을만한 시계를 만들기로 했다.
뭐 별다른 기능없이 그저 시계만 된다.
http://www.electroniccrafts.org/?n=Main.ClockDS1307
위 사이트가 원 제작자인데…
이제는 사이트가 열리질 않네요.
위 회로도 역시 원 제작자의 회로도이다.
원제작자의 형태를 기본으로 하고 나름데로 좀 수정 하였다.
원제작자의 경우 FND를 5V에 동작하는걸 이용하다보니 저항이 따로 없지만 국내에서는 구하기가 어렵고 금액이 비싸서 일반 FND를 사용하였다.
또한 스위치중 다운 스위치를 삭제하였다.
일단 1차적으로 브레드보드에 작업해서 잘 동작하는지 확인하였다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
// ------------------------------------------------------------------------------------- // TELL-TALE CLOCK: DS1307 Test Code. (July 22nd 2008) // ------------------------------------------------------------------------------------- // Display Code based on: Multiplex Common Anode, by Mouna Andraos (~11-8-2007) // from http://www.electroniccrafts.org // *Notes: -Pin numbers for connecting to arduino, use Digital output pins 2 to 13 // for 4 digit 7 segment display. // -Display model is: LITE-ON LTC-4627JS. // ------------------------------------------------------------------------------------- // DS1307 Interface Code based on: DS1307 Code by Maurice Ribble (4-17-2008) // from http://www.glacialwanderer.com/hobbyrobotics // *Notes: -This code tests the DS1307 Real Time clock on the Arduino board. // -The ds1307 works in binary coded decimal or BCD. // ------------------------------------------------------------------------------------- // ------------ DISPLAY MAP -------------- // A // --- // F /___ / B // G // E /___ / C // D // // --------------------------------------- // -------------------------------------------------------------------------------------- // DEFINE =============================================================================// // Add Library from I2C & specify DS1307 Adress #include "Wire.h" #define DS1307_I2C_ADDRESS 0x68 int cycle = 100; int f = 0; int i = 0; int m = 0; byte time_mode = 1; byte time_switch = 0; byte up_time = 0; byte down_time = 0; // Assign Adruino Pins int digit1 = 8; // 1 = common cathode(-) digit 1 int digit2 = 7; // 2 = common cathode(-) digit 2 int dots = 5; // 4 = common cathode(-) L1, L2, L3 --L1 & L2 are the : dots int digit3 = 3; // 6 = common cathode(-) digit 3 int digit4 = 1; // 8 = common cathode(-) digit 4 int D = 6; // 3 = anode D int E = 4; // 5 = anode E int DP = 2; // 7 = anode DP --decimal points int B = 9; // 16 = anode B, L2 int G = 10; // 15 = anode G int A = 11; // 14 = anode A, L1 int C = 12; // 13 = anode C, L3 int F = 13; // 11 = anode F int mode_pin = 16; // For button to change time display mode. int up_pin = 14; int down_pin = 15; int prog_mode = 1; boolean program = false; // Convert normal decimal numbers to binary coded decimal byte decToBcd(byte val) { return ( (val/10*16) + (val%10) ); } // Convert binary coded decimal to normal decimal numbers byte bcdToDec(byte val) { return ( (val/16*10) + (val%16) ); } // Stops the DS1307, but it has the side effect of setting seconds to 0 /*void stopDs1307() { Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.send(0); Wire.send(0x80); Wire.endTransmission(); }*/ // 1) Sets the date and time on the ds1307 // 2) Starts the clock // 3) Sets hour mode to 24 hour clock // Assumes you're passing in valid numbers void setDateDs1307 ( byte second, // 0-59 byte minute, // 0-59 byte hour, // 1-23 byte dayOfWeek, // 1-7 byte dayOfMonth, // 1-28/29/30/31 byte month, // 1-12 byte year // 0-99 ) { Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.send(0); Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock Wire.send(decToBcd(minute)); Wire.send(decToBcd(hour)); // If you want 12 hour am/pm you need to set // bit 6 (also need to change readDateDs1307) Wire.send(decToBcd(dayOfWeek)); Wire.send(decToBcd(dayOfMonth)); Wire.send(decToBcd(month)); Wire.send(decToBcd(year)); Wire.endTransmission(); } // Gets the date and time from the ds1307 void getDateDs1307 ( byte *second, byte *minute, byte *hour, byte *dayOfWeek, byte *dayOfMonth, byte *month, byte *year ) { // Reset the register pointer Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.send(0); Wire.endTransmission(); Wire.requestFrom(DS1307_I2C_ADDRESS, 7); // A few of these need masks because certain bits are control bits *second = bcdToDec(Wire.receive() & 0x7f); *minute = bcdToDec(Wire.receive()); *hour = bcdToDec(Wire.receive() & 0x3f); // Change this if 12 hour am/pm *dayOfWeek = bcdToDec(Wire.receive()); *dayOfMonth = bcdToDec(Wire.receive()); *month = bcdToDec(Wire.receive()); *year = bcdToDec(Wire.receive()); } // SETUP ================================+=============================================// void setup() { byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; Wire.begin(); //Serial.begin(9600); // For Testing // Change these values to what you want to set your clock to. second = 00; minute = 44; hour = 20; dayOfWeek = 2; dayOfMonth = 22; month = 07; year = 8; // Comment out the next line once time is set: // setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year); // Setup all digital outputs pinMode(digit1, OUTPUT); pinMode(digit2, OUTPUT); pinMode(digit3, OUTPUT); pinMode(digit4, OUTPUT); pinMode(dots, OUTPUT); pinMode(A, OUTPUT); pinMode(B, OUTPUT); pinMode(C, OUTPUT); pinMode(D, OUTPUT); pinMode(E, OUTPUT); pinMode(F, OUTPUT); pinMode(G, OUTPUT); pinMode(DP, OUTPUT); pinMode (mode_pin, INPUT); // Start with all the LEDS tured off = all pins HIGH PORTD = B11111111; // sets digital 2,3,4,5,6,7,8 to HIGH leaves 0 to HIGH (hopefully) PORTB = B11111; // sets digital 9,10,11,12,13) to HIGH digitalWrite(DP, LOW); //turn the decimal points off } // RUN ================================================================================// void loop() { mode(); } // FUNCTIONS ==========================================================================// void mode() { down_time = digitalRead(down_pin); up_time = digitalRead(up_pin); if (i == 0) { if (up_time == HIGH && down_time == HIGH) { if (time_mode < 4) { time_mode = time_mode + 1; } else { time_mode = 1; } i++; } } else if (i < 100) { i++; } else if (i==100) { program = true; i = 0; } if (program == true) { set_time(); } else { display_time(); } } // DISPLAY TIME AS SELECTED BY MODE void display_time() { // Get the data from the DS1307 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // Time Mode Switch time_switch = digitalRead(mode_pin); if (i == 0) { if (time_switch == HIGH) { if (time_mode < 4) { time_mode = time_mode + 1; } else { time_mode = 1; } i++; } } else if (i < 100) { i++; } else if (i==100) { i = 0; } // Time Mode 1: Hours & Minutes (Military Time) if (time_mode == 1) { byte t1 = hour/10; byte t2 = hour%10; byte t3 = minute/10; byte t4 = minute%10; if (second%2 == 0) { showTime(0,':'); } if (hour >9) { showTime(1,t1); } showTime(2,t2); showTime(3,t3); showTime(4,t4); } // Time Mode 2: Seconds Only if (time_mode == 2) { byte t3 = second/10; byte t4 = second%10; showTime(0,':'); showTime(3,t3); showTime(4,t4); } // Time Mode 3: Month & Day (of Month) if (time_mode == 3) { byte t1 = month/10; byte t2 = month%10; byte t3 = dayOfMonth/10; byte t4 = dayOfMonth%10; if (month >9) { showTime(1,t1); } showTime(2,t2); showTime(2,'.'); showTime(3,t3); showTime(4,t4); } // Time Mode 4: Year if (time_mode == 4) { byte t1 = 2; byte t2 = 0; byte t3 = year/10; byte t4 = year%10; showTime(1,t1); showTime(2,t2); showTime(3,t3); showTime(4,t4); } } //-------------------------------------------------------------------------------PROGRAM-------// void set_time() { // Program Mode Indicator showTime(4,'.'); // Read Buttons time_switch = digitalRead(mode_pin); down_time = digitalRead(down_pin); up_time = digitalRead(up_pin); // Declare Units of Time byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; // Mode 1: Get The Current Information from The DS1307 --------------- // if (prog_mode == 1) { getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); prog_mode = 2; } // ------------------------------------------------------------------- // // Mode 2: Set Year -------------------------------------------------- // // Display if (prog_mode == 2) { // Display the time byte t1 = 2; byte t2 = 0; byte t3 = year/10; byte t4 = year%10; showTime(1,t1); showTime(2,t2); showTime(3,t3); showTime(4,t4); // Set Uptime if (i == 0) { if (up_time == HIGH) { if (year < 99) { year = year + 1; } else { year = 0; } i++; } } // Set Downtime if (i == 0) { if (down_time == HIGH) { if (year > 1) { year = year - 1; } else { year = 99; } i++; } } // Complete button timer else if (i < 100) { i++; } else if (i==100) { i = 0; } // Move on to next unit to set if (m == 0) { if (time_switch == HIGH) { m++; } } else if (m < 200) { m++; } else if (m==200) { prog_mode = 3; m = 0; i = 0; } Serial.println(year); } // ------------------------------------------------------------------- // // Mode 3: Set Month ------------------------------------------------- // // Display if (prog_mode == 3) { // Display the time byte t1 = month/10; byte t2 = month%10; showTime(1,t1); showTime(2,t2); // Set Uptime if (i == 0) { if (up_time == HIGH) { if (month < 12) { month = month + 1; } else { month = 1; } i++; } } // Set Downtime if (i == 0) { if (down_time == HIGH) { if (month > 1) { month = month - 1; } else { month = 12; } i++; } } // Complete button timer else if (i < 100) { i++; } else if (i==100) { i = 0; } // Move on to next unit to set if (m == 0) { if (time_switch == HIGH) { m++; } } else if (m < 200) { m++; } else if (m==200) { prog_mode = 4; m = 0; i = 0; } Serial.println(month); } // ------------------------------------------------------------------- // // Mode 4: Set Day of Month ------------------------------------------ // // Display if (prog_mode == 4) { // Display the time byte t3 = dayOfMonth/10; byte t4 = dayOfMonth%10; showTime(3,t3); showTime(4,t4); // Set Uptime if (i == 0) { if (up_time == HIGH) { if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { if (dayOfMonth < 31) { dayOfMonth = dayOfMonth + 1; } else { dayOfMonth = 1; } } if (month == 4 || month == 6 || month == 9 || month == 11) { if (dayOfMonth < 30) { dayOfMonth = dayOfMonth + 1; } else { dayOfMonth = 1; } } if (month == 2) { if (year%4 == 0) { if (dayOfMonth < 29) { dayOfMonth = dayOfMonth + 1; } else { dayOfMonth = 1; } } else { if (dayOfMonth < 28) { dayOfMonth = dayOfMonth + 1; } else { dayOfMonth = 1; } } } i++; } } // Set Downtime if (i == 0) { if (down_time == HIGH) { if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { if (dayOfMonth > 1) { dayOfMonth = dayOfMonth - 1; } else { dayOfMonth = 31; } } if (month == 4 || month == 6 || month == 9 || month == 11) { if (dayOfMonth > 1) { dayOfMonth = dayOfMonth - 1; } else { dayOfMonth = 30; } } if (month == 2) { if (year%4 == 0) { if (dayOfMonth > 1) { dayOfMonth = dayOfMonth - 1; } else { dayOfMonth = 29; } } else { if (dayOfMonth > 1) { dayOfMonth = dayOfMonth - 1; } else { dayOfMonth = 28; } } } i++; } } // Complete button timer else if (i < 100) { i++; } else if (i==100) { i = 0; } // Move on to next unit to set if (m == 0) { if (time_switch == HIGH) { m++; } } else if (m < 200) { m++; } else if (m==200) { prog_mode = 5; m = 0; i = 0; } Serial.println(dayOfMonth); } // ------------------------------------------------------------------- // // Mode 5: Set Day of Week ------------------------------------------- // // Display if (prog_mode == 5) { // Display the time byte t4 = dayOfWeek; showTime(4,t4); // Set Uptime if (i == 0) { if (up_time == HIGH) { if (dayOfWeek < 7) { dayOfWeek = dayOfWeek + 1; } else { dayOfWeek = 1; } i++; } } // Set Downtime if (i == 0) { if (down_time == HIGH) { if (dayOfWeek > 1) { dayOfWeek = dayOfWeek - 1; } else { dayOfWeek = 7; } i++; } } // Complete button timer else if (i < 200) { i++; } else if (i==200) { i = 0; } // Move on to next unit to set if (m == 0) { if (time_switch == HIGH) { m++; } } else if (m < 200) { m++; } else if (m==200) { prog_mode = 6; m = 0; i = 0; } Serial.println(dayOfWeek); } // ------------------------------------------------------------------- // // Mode 6: Set Hours ------------------------------------------------- // // Display if (prog_mode == 6) { // Display the time byte t1 = hour/10; byte t2 = hour%10; showTime(1,t1); showTime(2,t2); // Set Uptime if (i == 0) { if (up_time == HIGH) { if (hour < 23) { hour = hour + 1; } else { hour = 0; } i++; } } // Set Downtime if (i == 0) { if (down_time == HIGH) { if (hour > 0) { hour = hour - 1; } else { hour = 23; } i++; } } // Complete button timer else if (i < 100) { i++; } else if (i==100) { i = 0; } // Move on to next unit to set if (m == 0) { if (time_switch == HIGH) { m++; } } else if (m < 200) { m++; } else if (m==200) { prog_mode = 7; m = 0; i = 0; } Serial.println(hour); } // ------------------------------------------------------------------- // // Mode 7: Set Minutes ----------------------------------------------- // // Display if (prog_mode == 7) { // Display the time byte t3 = minute/10; byte t4 = minute%10; showTime(3,t3); showTime(4,t4); // Set Uptime if (i == 0) { if (up_time == HIGH) { if (minute < 59) { minute = minute + 1; } else { minute = 0; } i++; } } // Set Downtime if (i == 0) { if (down_time == HIGH) { if (minute > 0) { minute = minute - 1; } else { minute = 23; } i++; } } // Complete button timer else if (i < 100) { i++; } else if (i==100) { i = 0; } // Move on to next unit to set if (m == 0) { if (time_switch == HIGH) { m++; } } else if (m < 200) { m++; } else if (m==200) { prog_mode = 8; m = 0; i = 0; } Serial.println(minute); } // ------------------------------------------------------------------- // // Mode 8: Program the DS1307 & exit program mode -------------------- // if (prog_mode == 8) { second = 0; setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year); program = false; prog_mode = 1; m = 0; i = 0; } // ------------------------------------------------------------------- // } //-------------------------------------------------------------------------------PROGRAM-------// // LIGHT-UP A DIGIT // (Combines the next 3 functions into 1 simple call) void showTime(byte k, char j) { position(k); turn(j); off(); } // 7-SEGMENT DIGIT SELECTOR void position(byte pos) { // DIGIT 1 -------------------- if (pos == 1) { digitalWrite(digit1, LOW); digitalWrite(digit2, HIGH); digitalWrite(digit3, HIGH); digitalWrite(digit4, HIGH); digitalWrite(dots, HIGH); } // DIGIT 2 -------------------- if (pos == 2) { digitalWrite(digit1, HIGH); digitalWrite(digit2, LOW); digitalWrite(digit3, HIGH); digitalWrite(digit4, HIGH); digitalWrite(dots, HIGH); } // COLON ---------------------- if (pos == 0) { digitalWrite(digit1, HIGH); digitalWrite(digit2, HIGH); digitalWrite(digit3, HIGH); digitalWrite(digit4, HIGH); digitalWrite(dots, LOW); } // DIGIT 3 -------------------- if (pos == 3) { digitalWrite(digit1, HIGH); digitalWrite(digit2, HIGH); digitalWrite(digit3, LOW); digitalWrite(digit4, HIGH); digitalWrite(dots, HIGH); } // DIGIT 4 -------------------- if (pos == 4) { digitalWrite(digit1, HIGH); digitalWrite(digit2, HIGH); digitalWrite(digit3, HIGH); digitalWrite(digit4, LOW); digitalWrite(dots, HIGH); } } // TURN OFF DISPLAY // (Eliminates "Light Shadows" from one digit to the next) void off() { digitalWrite(A, LOW); digitalWrite(B, LOW); digitalWrite(C, LOW); digitalWrite(D, LOW); digitalWrite(E, LOW); digitalWrite(F, LOW); digitalWrite(G, LOW); digitalWrite(DP, LOW); delayMicroseconds(50); } // DIGIT CREATION FUNCTIONS ------------ void turn(char num) { //-----------------------------// 0 if (num == 0) { digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, HIGH); digitalWrite(E, HIGH); digitalWrite(F, HIGH); digitalWrite(G, LOW); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 1 if (num == 1) { digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, LOW); digitalWrite(E, LOW); digitalWrite(F, LOW); digitalWrite(G, LOW); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 2 if (num == 2) { digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, LOW); digitalWrite(D, HIGH); digitalWrite(E, HIGH); digitalWrite(F, LOW); digitalWrite(G, HIGH); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 3 if (num == 3) { digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, HIGH); digitalWrite(E, LOW); digitalWrite(F, LOW); digitalWrite(G, HIGH); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 4 if (num == 4) { digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, LOW); digitalWrite(E, LOW); digitalWrite(F, HIGH); digitalWrite(G, HIGH); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 5 if (num == 5) { digitalWrite(A, HIGH); digitalWrite(B, LOW); digitalWrite(C, HIGH); digitalWrite(D, HIGH); digitalWrite(E, LOW); digitalWrite(F, HIGH); digitalWrite(G, HIGH); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 6 if (num == 6) { digitalWrite(A, HIGH); digitalWrite(B, LOW); digitalWrite(C, HIGH); digitalWrite(D, HIGH); digitalWrite(E, HIGH); digitalWrite(F, HIGH); digitalWrite(G, HIGH); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 7 if (num == 7) { digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, LOW); digitalWrite(E, LOW); digitalWrite(F, LOW); digitalWrite(G, LOW); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 8 if (num == 8) { digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, HIGH); digitalWrite(E, HIGH); digitalWrite(F, HIGH); digitalWrite(G, HIGH); digitalWrite(DP, LOW); delay(1); } //-----------------------------// 9 if (num == 9) { digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, HIGH); digitalWrite(D, HIGH); digitalWrite(E, LOW); digitalWrite(F, HIGH); digitalWrite(G, HIGH); digitalWrite(DP, LOW); delay(1); } //-----------------------------// : if (num == ':') { digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, LOW); digitalWrite(D, LOW); digitalWrite(E, LOW); digitalWrite(F, LOW); digitalWrite(G, LOW); digitalWrite(DP, LOW); delay(1); } //-----------------------------// : if (num == '.') { digitalWrite(A, LOW); digitalWrite(B, LOW); digitalWrite(C, LOW); digitalWrite(D, LOW); digitalWrite(E, LOW); digitalWrite(F, LOW); digitalWrite(G, LOW); digitalWrite(DP, HIGH); delay(1); } if (num == 'F') { digitalWrite(A, LOW); digitalWrite(B, LOW); digitalWrite(C, LOW); digitalWrite(D, LOW); digitalWrite(E, LOW); digitalWrite(F, LOW); digitalWrite(G, LOW); digitalWrite(DP, LOW); delay(1); } } //-------------------------------------- |
위는 원 제작자의 소스이다.
물론 이것 저것 수정해서 썼다.
해당 하드웨어와 소스만으로도 충분히 작동 가능하다.
때에 따라서 안되는 부분이 있다면 컴파일러 버젼이나 약간의 설정부분의 변경등이다.
만약 만들어 본다면 처음부터 다 할려는 것보다…
한개씩 조금씩 해보는게 좋을 듯 하다.
시간을 읽어오고 설정하는것부터 해보고…
그러면서 FND에 표현 해보고…
그리고 시간 설정하는 루틴도 짜보고…
등등…
예전에는 브레드보드가 있음에도 전혀 쓰질 않았는데…
이렇게 편리한걸 왜 안쓰고 일일이 납땜했는지 모르겠다. ^^;
브레드보드를 잘 쓰는건 아니라서… ^^;
암튼…
생각해준데로 잘~ 동작한다.
Atmega8에 스케치가 업로드 될 수 있도록 스케치 역시 수정하여 용량을 낮추었다.
브레드보드에서 잘 동작했으니…
보드를 제작하였다.
그냥 보드단으로 끝을 낼게 아니라 케이스까지 생각해서 완성도를 높이기로 하였다.
적당한 싸이즈의 케이스를 찾다보니 6mm 비디오 테이프…
기본적으로 FND와 Atmega8, 저항등을 넣었을때 거의 딱 맞는 수준이였다.
케이스에 들어갈만한 크기를 찾아내서 해당 크기안에서 부품들을 배치하고 연결까지 가능한지 확인하였다.
부품만 꽂아봐도 큰 무리없이 진행될 수 있어서 제작에 들어 갔다.
아래는 제작완료된 보드의 모습이다.
처음 생각했던 형태로 진행되었다.
그리고 6mm 비디오 테이프 케이스 안에 넣고 동작시키는 모습이다.
큰 어려움 없이 제작할 수 있었다.
물론 최소한의 기능으로만 제작하다보니 스케치도 간단하고… ^^;
부품은 아래와 같이 이용되었다.
열심히 해봐야 겠다.
이런 저런 이유로 자세한 제작과정을 여기에는 담지 못하였다.
조만간에 담을 수 있도록 해야 겠다.
아두이노 시작 D-2 인 초보입니다.
잘 읽고 많은 정보 얻어 갑니다.
비디오 케이스가 대박 입니다.~~
D-2 이라 함은 아직 시작 안하신건가요?
이틀뒤에 아두이노가 도착?
아니면 이틀 되신건가요? ^^;
열심히 하시길 바래요.
많은 도움 드릴 수 있으면 드리도록 할께요.
^^;
비디오 테이프 케이스 말고도 다양한거 많아요.
다이소 같은데서 파는 저렴한 반찬통도 있어요. ^^;
감사합니다.
혹시 부품 재료 이름들 알수있을까요??ㅜ
우선 제가 비디오 테이프에 담은 시계 기준으로 말씀드릴께요~
아두이노 클론 타입이라 보시면 되구요.
아두이노에 사용되는 동일한 MCU를 사용하였습니다.
그리고 아두이노를 통해 부트로드를 업로드 하였구요.
Atmega328
DS1307
7-Segments
Crystal 32.768KHz
Crystal 16MHz
저항 330옴 – 9개
저항 10k옴 – 5개
저항 0옴 – 1개
콘덴서 22pF – 2개
콘덴서 0.1uF – 1개
Switch – 3개
전지홀더
CR2032
IC소켓 28pin
IC소켓 8pin
핀헤더
Micro USB (시계 전원용)
만능기판
USB to UART (스케치 업로드용, 아두이노 우노로 대체 가능)
위와 같이 사용하였습니다.
수량이 안적힌것은 1개 입니다.
뭐 여러가지 기능을 위해 다른 부품들도 가능하구요.
도움이 되었으면 하네요~
혹시라도 제작을 하심에 있어 궁금한게 있으시면 언제든지 물어보세요~ ^^;
가까우면 오프라인으로 만나서라도… ^^;
시계형 세그먼트를 s-5462asr2/c 로 사용하려고 하는데요 핀을 어떻게 연결시켜야 할지 잘 모르겠어요
ds1307과 다른건가요?
s-5462asr2/c로 사용할 땐 어떻게 연결해야하나요?
해당 세그먼트의 데이터쉬트를 참고해보셔야 할것 같네요~
http://www.ds-parts.co.kr/goods_detail.php?goodsIdx=5815
사실 세그먼트는 데이터쉬트가 잘 나와있는게 잘 없습니다.
보통은 제가 적어드린 정도?
해당 데이터쉬트를 보면 알수도(?) 있지만… 어느쪽이 1번으로 칭해야 할지 많이 헷갈립니다.
그럴땐 5V에 330옴 정도 저항 하나 연결해서 하나씩 찍어보는게 좋습니다.
아주 잠깐 찍어 보았을때 불이 들어오는지 안오는지…
그렇게 해서 1번과 14번의 위치를 찾으면 나머지는 데이터쉬트에 나와있는 형태로 연결하시면 됩니다.
제 소스에 앞쪽에 Assign Arduino Pins에 나와 있듯이 해당 핀과 연결 해주시면 되구요
혹시 하시다가 잘 안되는 부분이 있다면 언제든지 글 달아주세요~
감사합니다.
맨 위 첨부된 사진에 세그먼트 핀을 보면 핀이 16개인데 4digit세그먼트는 핀이 14개 아닌가요?
세그먼트에 따라 조금씩 다릅니다.
제일 상단의 회로도의 경우는 원제작자가 올린 회로도 입니다.
그래서 조금 다른 세그먼트를 사용한것 같네요~
세그먼트에 표시되는 내용이 많으면 많을 수록 핀이 더 들어갑니다. ^^;
자세한것은 구매하신 세그먼트의 데이터쉬트를 살펴보셔야 할것 같습니다.
잘 보고 많이 배워 갑니다.
많은 정보도 못드렸는데 죄송합니다.
그리 배울게… ㅠㅜ
응원에 힘입어 좀더 열심히 활동 해야 겠습니다.
바쁘다는 핑계로 너무 소홀히 하는 것 같네요~
감사합니다.
http://m.kin.naver.com/mobile/qna/detail.nhn?d1Id=11&dirId=1118&docId=235531771
제가지식인에 올린 글 입니다. ..제발 도와주세요
숙제도 아니고 필요하기에 만들고 싶은건데 도와주질 않아요…막막해요 아두이노 시작하지 2개월이 지나가고 있는데…막히네요…
어떤 부분을 도와 드릴까요?
아~ 지식인…
살펴보도록 하겠습니다. ^^;
봐주심 감사드립니다.
RTC(DS1307)+아두이노(UNO-3)+1602 CLCD +
설정스위치1개+시간UP스위치 1개로
위에 UP스위치로 알람도 끄게 할수 있게
알람시계를 만드려고 하는데요 소스는 어떻게 짜야할까요??
소스좀 알려주세요~
imho002@naver.com
소스는 제가 짜놓은거랑 큰 차이는 없습니다
RTC를 이용함으로써 시간 계산하는 부분이 없으니 편합니다
무엇보다 LCD로 출력하니 FND보다 간단 하구요
LCD는 사용 가능 하시지요?
제 소스 보시면 사용한 변수 이름들이 대충 보면 뭘 뜻하는지 아실겁니다
시(10) 시(1) 분(10) 분(1) 이렇게 나옵니다
이를 LCD에 뿌려 주기만 하면 됩니다
설정 버튼으로 상태를 변화시키면서
현재시간 표시
현재시간 시 설정
현재시간 분 설정
알람시간 시 설정
알람시간 분 설정
알람 여부 설정
이런식으로 변화시키면 될듯 하네요
알람 울리는건
알람여부에 따라서
알람을 사용 한다면
지금 시간과 알람 시간을 비교해보는 거죠
맞다면 알람을 울리면 되구요
알림끄기 버튼으로 알람이 울릴때 알람끄기 버튼이 들어오면 알람을 끄면 될듯 합니다
한번에 다 하려고 하지 마시고
하나씩 해보세요
1. 그저 LCD 자유롭게 다루기
2. RTC값 받아오기
3. 받아온 RTC값 표현하기
4. 버튼입력을 받아서 LCD에 표시하기
5. 버튼입력으로 RTC로 받아온값 다르게 표시하기
6. 시간 설정 해보기
7. 알람 시간만 설정 해보기
8. 알람 시간에 LED로 표시 해보기
9. 알람 시간에 알람 울리기
10. 알람 울릴때 버튼 입력으로 꺼보기
등으로 진행 해보면 될것 같네요
하나씩 성공해서 넘어가면 쉽게 하실 수 있을 겁니다
저도 한번 만들어 봐야겠네요 ^^
친절하신 답변 감사합니다.
제가 5번까지는 해보구요 6번두 해보긴 해밨는데…알람은 예제랑 소스를 잘못찾겟어서…못해밨거든요…알람시간을 설정해서 설정한값이 LCD화면에 현재시간이랑 같이 나오도록 하려고 하거든요…
어렵네요…한번 참고해서 해보겠습니다… 감사합니다.
예제를 찾아서 하기에는 쉽지 않을 수 있습니다.
내 입맛에 맞는것도 잘 없고…
그렇다 치면 직접 만드는 수 밖에 없어요.
LCD가 두줄 이상 짜리라면…
윗줄 아랫줄 분리해서 현재시간과 알람시간을 표시하면 될것 같습니다.
처음에는 현재시간과 내가 출력하고 싶은 글(시간으로 표현하면 되겠죠?)을 해보시고…
그리고 알람 시간을 변수화 해서 표현 해보세요~
그 변수화한 알람 시간을 설정해서 바꿀 수 있도록 하구요~
그러면서 하나씩 진행하시면 됩니다.
한방에 되는건 잘 없습니다.
대부분의 실력자 역시 하나하나 차근차근 진행합니다.
그래야 혹시 문제가 있더라도 어디서 문제가 되는지 확인이 쉬우니깐 말이죠~
알람 시간은 또다른 변수이고 그저 이 변수값을 바꾼다 라고만 생각하세요~
실제 알람 기능은 아직 생각지 마시구요~
이상없이 값이 바뀌고 표현이 되고나면 그때서야 실제 알람 기능을 생각하시면 됩니다.
제가 이번에 과제로 아두이노를 활용해서 해볼려고 알려주신 부품을 구입해서
사진에서 보여준대로 납땜도 하고 프로그램으로 소스를 컴파일 해봤는데
오류가 많이 나오더라구요… 좀 도와주세요!!!
그리고 뒷면 사진이 없어서 어떻게 해야할지를 모르겠어요… 아두이노를 배워본적이
한번도 없는 초짜입니다ㅠㅠ
안녕하세요
우선은 하드웨어 결선과 소프트웨어를 확실히 알아야 할것 같네요
그래야 제가 도와주실 수 있을것 같습니다
실제 결선한 사진 등이 있으면 좋군요
실제 업로드한 프로그램 코드도 있으면 좋구요
납땜 보다는 빵판에 먼저 작업을 하시는게 편리하긴합니다
답글 달아주신 곳으로 메일 보내겠습니다
감사합니다
Hi. I see that you don’t update your site too often. I know that writing articles is boring
and time consuming. But did you know that there is a tool that allows you to create new posts using existing
content (from article directories or other websites from your niche)?
And it does it very well. The new articles are high
quality and pass the copyscape test. You should try miftolo’s tools