Project description
Code
Arduino based Automatic School Bell System
h
1//Program to 2 3#include <Wire.h> 4 5#include<EEPROM.h> 6 7#include 8 "RTClib.h" 9 10#include <LiquidCrystal.h> 11 12LiquidCrystal lcd(13, 12, 13 6, 5, 4, 3);// Pins used for RS,E,D4,D5,D6,D7 14 15RTC_DS1307 rtc; 16 17char* 18 mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"}; 19 20char 21 daysOfTheWeek[7][12] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}; 22 23int 24 subject[7]; 25 26int buzzer=A4;//Pin declare for buzzer control at pin number 27 24 of arduino mega 28 29int b1 = A0; // the number of the pushbutton pin 30 31int 32 b2 = A1; // the number of the LED pin 33 34int 35 b3 = A2; // the number of the LED pin 36 37int b4 = A3; // the number 38 of the LED pin 39 40int bS1 = 0; 41 42int bS2 = 0; 43 44int 45 bS3 = 0; 46 47int bS4 = 0; 48 49int newTime,newHour,prevTime=0,prevHour=0,a=0,hoursE=0,hoursH=0, 50 countTime=60; 51 52int i=0,j=0,k=0,var,nextSUB=0,value,pos=0,periodtime=0,starttime=0,endtime=0,totaltime=0,break1=0,break2=0; 53 54 55int monA=6,tueA=12,wedA=17,thuA=22,friA=27,satA=32,brk1,brk2,noPeriod=0; 56 57int 58 HOUR,MINUT,SECOND,timeH,timeM,setT=0,breakR=0; 59 60 61 62byte Aalpha[8] ={ 63 0b00000, 64 65 0b01110, 66 67 0b10001, 68 69 70 0b11111, 71 72 0b10001, 73 74 0b10001, 75 76 77 0b00000, 78 79 0b00000 80 81 }; 82 83 84 byte Balpha[8]={ 0b00000, 85 86 0b11100, 87 88 0b10010, 89 90 91 0b11100, 92 93 0b10010, 94 95 0b11100, 96 97 98 0b00000, 99 100 0b00000}; 101 102 byte 103 Calpha[8]={ 0b00000, 104 105 0b01110, 106 107 0b10000, 108 109 110 0b10000, 111 112 0b10000, 113 114 0b01110, 115 116 117 0b00000, 118 119 0b00000}; 120 121 122 byte Dalpha[8] ={ 0b00000, 123 124 0b11100, 125 126 0b10010, 127 128 129 0b10010, 130 131 0b10010, 132 133 0b11100, 134 135 136 0b00000, 137 138 0b00000}; 139 140 byte Ealpha[8] 141 ={0b00000, 142 143 0b11110, 144 145 0b10000, 146 147 148 0b11100, 149 150 0b10000, 151 152 0b11110, 153 154 155 0b00000, 156 157 0b00000}; 158 159 byte Falpha[8] 160 ={0b00000, 161 162 0b11110, 163 164 0b10000, 165 166 167 0b11100, 168 169 0b10000, 170 171 0b10000, 172 173 174 0b00000, 175 176 0b00000}; 177 178 byte 179 Galpha[8]={0b00000, 180 181 0b01110, 182 183 0b10000, 184 185 186 0b10110, 187 188 0b10010, 189 190 0b01110, 191 192 193 0b00000, 194 195 0b00000}; 196 197 byte 198 Halpha[8] ={ 0b00000, 199 200 0b10001, 201 202 0b10001, 203 204 205 0b11111, 206 207 0b10001, 208 209 0b10001, 210 211 212 0b00000, 213 214 0b00000}; 215 216 byte 217 Ialpha[8]={0b00000, 218 219 0b01110, 220 221 0b00100, 222 223 224 0b00100, 225 226 0b00100, 227 228 0b01110, 229 230 231 0b00000, 232 233 0b00000}; 234 235 byte 236 Lalpha[8]={ 0b00000, 237 238 0b10000, 239 240 0b10000, 241 242 243 0b10000, 244 245 0b10000, 246 247 0b11110, 248 249 250 0b00000, 251 252 0b00000}; 253 254 byte 255 Malpha[8] ={ 0b00000, 256 257 0b10001, 258 259 0b11011, 260 261 262 0b10101, 263 264 0b10001, 265 266 0b10001, 267 268 269 0b00000, 270 271 0b00000}; 272 273 274 byte Nalpha[8] ={0b00000, 275 276 0b10001, 277 278 0b11001, 279 280 281 0b10101, 282 283 0b10011, 284 285 0b10001, 286 287 288 0b00000, 289 290 0b00000}; 291 292 byte 293 Oalpha[8]={ 0b00000, 294 295 0b01110, 296 297 0b10001, 298 299 300 0b10001, 301 302 0b10001, 303 304 0b01110, 305 306 307 0b00000, 308 309 0b00000}; 310 311 byte 312 Palpha[8]={ 0b00000, 313 314 0b11100, 315 316 0b10010, 317 318 319 0b11100, 320 321 0b10000, 322 323 0b10000, 324 325 326 0b00000, 327 328 0b00000}; 329 330 331 byte Ralpha[8]={ 0b00000, 332 333 0b11110, 334 335 0b10001, 336 337 338 0b11110, 339 340 0b10100, 341 342 0b10010, 343 344 345 0b00000, 346 347 0b00000}; 348 349 350 byte Salpha[8] ={ 0b00000, 351 352 0b01110, 353 354 0b10000, 355 356 357 0b01110, 358 359 0b00001, 360 361 0b01110, 362 363 364 0b00000, 365 366 0b00000}; 367 368 byte 369 Talpha[8] ={0b00000, 370 371 0b11111, 372 373 0b00100, 374 375 376 0b00100, 377 378 0b00100, 379 380 0b00100, 381 382 383 0b00000, 384 385 0b00000}; 386 387 388 389 390 byte Ualpha[8]={ 0b00000, 391 392 0b10001, 393 394 0b10001, 395 396 397 0b10001, 398 399 0b10001, 400 401 0b01110, 402 403 404 0b00000, 405 406 0b00000}; 407 408 409 byte Walpha[8] ={ 0b00000, 410 411 0b10001, 412 413 0b10001, 414 415 416 0b10101, 417 418 0b11011, 419 420 0b10001, 421 422 423 0b00000, 424 425 0b00000}; 426 427 byte 428 Yalpha[8]={ 0b00000, 429 430 0b10001, 431 432 0b10001, 433 434 435 0b01010, 436 437 0b00100, 438 439 0b00100, 440 441 442 0b00000, 443 444 0b00000}; 445 446 447 448 449 byte next[8]={0b00000, 450 451 0b10000, 452 453 0b01000, 454 455 456 0b00100, 457 458 0b01000, 459 460 0b10000, 461 462 463 0b00000, 464 465 0b00000 466 467 }; 468 469 470 471void setup() { 472 473 Wire.begin(); 474 475 476 rtc.begin(); 477 478 Serial.begin(9600); //Software serial initialization 479 480 481 pinMode(b1, INPUT); 482 483 pinMode(b2, INPUT); 484 485 pinMode(b3, INPUT); 486 487 488 pinMode(b4, INPUT); 489 490 pinMode( buzzer, OUTPUT ); 491 492 digitalWrite( 493 buzzer, LOW ); 494 495 lcd.begin(16,2); 496 497 lcd.setCursor(0,0); 498 499 500 lcd.print("Engineers Garage"); 501 502 lcd.setCursor(0,1); 503 504 lcd.print(" 505 TIME TABLE "); 506 507 delay(3000); 508 509 if (! rtc.isrunning()) { 510 511 512 Serial.println("RTC is NOT running!"); 513 514 // following line sets the 515 RTC to the date & time this sketch was compiled 516 517 rtc.adjust(DateTime(F(__DATE__), 518 F(__TIME__))); 519 520 } 521 522 delay(3000); 523 524 lcd.clear(); 525 526lcd.setCursor(0,0); 527 528lcd.print(" 529 ENTER ALL INFO "); 530 531lcd.setCursor(0,1); 532 533lcd.print(" YES* NO# 534 "); 535 536} 537 538 539void loop() { 540 541bS1 = digitalRead(b1); 542 543bS2 544 = digitalRead(b2); 545 546bS3 = digitalRead(b3); 547 548bS4 = digitalRead(b4); 549 550 551if(bS1==LOW){ 552 553 554 pos=20; 555 556 DateTime now =rtc.now(); 557 558 prevTime=now.minute(); 559 560 561 prevHour=now.hour(); 562 563 Serial.println(prevHour); 564 565 Serial.println(prevTime); 566 567 568 Serial.println(EEPROM.read(4)); 569 570 lcd.clear();} 571 572if(bS4==LOW){ 573 574 575 pos=30; 576 577 DateTime now =rtc.now(); 578 579 prevTime=now.minute(); 580 581 582 prevHour=now.hour(); 583 584 hoursE = EEPROM.read(4);//Period time delay 585 586 587 Serial.println(prevHour); 588 589 Serial.println(prevTime); 590 591 Serial.println(EEPROM.read(4)); 592 593 594 lcd.clear();} 595 596while(pos==20){ 597 598 pos=0; 599 600 delay(1000); 601 602 603 lcd.clear(); 604 605 while(pos==0){ 606 607 bS1 = digitalRead(b1); 608 609 610 bS2 = digitalRead(b2); 611 612 bS3 = digitalRead(b3); 613 614 bS4 = digitalRead(b4); 615 616 617 lcd.setCursor(0,0); 618 619 lcd.print("ENTER START TIME"); 620 621 if(bS1==LOW 622 && pos==0){ 623 624 lcd.setCursor(5,1); 625 626 starttime++; 627 628 printDigits2(starttime); 629 630 631 lcd.setCursor(8,1); 632 633 lcd.print("O' clock"); 634 635 EEPROM.write(5,starttime); 636 637 638 delay(200); 639 640 if(starttime==24) 641 642 starttime=0; 643 644 } 645 646 647 if(bS4==LOW && pos==0){ 648 649 prevHour=starttime; 650 651 lcd.setCursor(0,0); 652 653 654 lcd.print(" *****SAVED**** "); 655 656 EEPROM.write(0,starttime); 657 658 659 Serial.println(starttime); 660 661 delay(1000); 662 663 pos=1; 664 665 666 lcd.clear(); 667 668 break; 669 670 } 671 672 } 673 674 while(pos==1){ 675 676 677 bS1 = digitalRead(b1); 678 679 bS2 = digitalRead(b2); 680 681 bS3 = digitalRead(b3); 682 683 684 bS4 = digitalRead(b4); 685 686 lcd.setCursor(0,0); 687 688 lcd.print(" 689 ENTER END TIME "); 690 691 if(bS1==LOW && pos==1){ 692 693 694 695 lcd.setCursor(5,1); 696 697 698 endtime++; 699 700 printDigits2(endtime); 701 702 lcd.setCursor(7,1); 703 704 705 lcd.print("O' clock"); 706 707 delay(200); 708 709 if(endtime==24) 710 711 712 endtime=0; 713 714 } 715 716 if(bS4==LOW && pos==1){ 717 718 lcd.setCursor(0,0); 719 720 721 lcd.print(" *****SAVED**** "); 722 723 EEPROM.write(1,endtime); 724 725 726 Serial.println(endtime); 727 728 delay(1000); 729 730 pos=2; 731 732 733 lcd.clear(); 734 735 break; 736 737 } 738 739 } 740 741 while(pos==2){ 742 743 744 bS1 = digitalRead(b1); 745 746 bS2 = digitalRead(b2); 747 748 bS3 = digitalRead(b3); 749 750 751 bS4 = digitalRead(b4); 752 753 lcd.setCursor(0,0); 754 755 lcd.print(" 756 FIRST BRK TIME "); 757 758 if(bS1==LOW && pos==2){ 759 760 lcd.setCursor(5,1); 761 762 763 break1++; 764 765 printDigits2(break1); 766 767 lcd.setCursor(8,1); 768 769 770 lcd.print("minutes"); 771 772 delay(200); 773 774 if(break1==40) 775 776 777 break1=0; 778 779 } 780 781 if(bS4==LOW && pos==2){ 782 783 lcd.setCursor(0,0); 784 785 786 lcd.print(" *****SAVED**** "); 787 788 EEPROM.write(2,break1); 789 790 791 Serial.println(break1); 792 793 delay(1000); 794 795 pos=3; 796 797 798 lcd.clear(); 799 800 break; 801 802 } 803 804 } 805 806 while(pos==3){ 807 808 809 bS1 = digitalRead(b1); 810 811 bS2 = digitalRead(b2); 812 813 bS3 = digitalRead(b3); 814 815 816 bS4 = digitalRead(b4); 817 818 lcd.setCursor(0,0); 819 820 lcd.print("SECOND 821 BRK TIME "); 822 823 if(bS1==LOW && pos==3){ 824 825 lcd.setCursor(5,1); 826 827 828 break2++; 829 830 printDigits2(break2); 831 832 lcd.setCursor(8,1); 833 834 835 lcd.print("minutes"); 836 837 delay(200); 838 839 if(break2==40) 840 841 842 break2=0; 843 844 } 845 846 if(bS4==LOW && pos==3){ 847 848 lcd.setCursor(0,0); 849 850 851 lcd.print(" *****SAVED**** "); 852 853 EEPROM.write(3,break2); 854 855 856 Serial.println(break2); 857 858 delay(1000); 859 860 pos=4; 861 862 863 lcd.clear(); 864 865 break; 866 867 } 868 869 } 870 871/*Slection 872 of subject DAY wise*/ 873 874while(pos==4){ 875 876 bS1 = digitalRead(b1); 877 878 879 bS2 = digitalRead(b2); 880 881 bS3 = digitalRead(b3); 882 883 bS4 = digitalRead(b4); 884 885 886 lcd.setCursor(0,0); 887 888 lcd.print("SLCT MONDAY SUB "); 889 890 if(bS1==LOW 891 && pos==4){ 892 893 if(i>0){ 894 895 i--; 896 897 delay(400); 898 899 900 lcd.setCursor(6,1); 901 902 lcd.print(" "); 903 904 } 905 906 lcd.setCursor(6,1); 907 908 909 lcd.print(mySubject[i]); 910 911 } 912 913 if(bS2==LOW && pos==4){ 914 915 916 if(i<7){ 917 918 i++; 919 920 delay(400); 921 922 lcd.setCursor(6,1); 923 924 925 lcd.print(" "); 926 927 } 928 929 lcd.setCursor(6,1); 930 931 932 lcd.print(mySubject[i]); 933 934 } 935 936 if(bS4==LOW && pos==4){ 937 938 939 EEPROM.write(j+6,i); 940 941 lcd.setCursor(0,0); 942 943 lcd.print(" 944 *****SAVED**** "); 945 946 Serial.print(j+6); 947 948 Serial.println(i); 949 950 951 delay(1000); 952 953 lcd.clear(); 954 955 j++; 956 957 } 958 959if(bS3==LOW 960 && pos==4){ 961 962 lcd.setCursor(0,0); 963 964 lcd.print("*SUB SAVED 965 MON*"); 966 967 delay(1000); 968 969 lcd.setCursor(0,1); 970 971 lcd.print(" 972 THANK YOU "); 973 974 pos=5; 975 976 delay(3000); 977 978 lcd.clear(); 979 980 981 break; 982 983} 984 985 } 986 987 /*Subject selection for TUESDAY*/ 988 989 990 while(pos==5){ 991 992 bS1 = digitalRead(b1); 993 994 bS2 = digitalRead(b2); 995 996 997 bS3 = digitalRead(b3); 998 999 bS4 = digitalRead(b4); 1000 1001 lcd.setCursor(0,0); 1002 1003 1004 lcd.print("SLCT TUESDAY SUB"); 1005 1006 if(bS1==LOW && pos==5){ 1007 1008 1009 if(i>0){ 1010 1011 i--; 1012 1013 delay(400); 1014 1015 lcd.setCursor(6,1); 1016 1017 1018 lcd.print(" "); 1019 1020 } 1021 1022 lcd.setCursor(6,1); 1023 1024 lcd.print(mySubject[i]); 1025 1026 1027 } 1028 1029 if(bS2==LOW && pos==5){ 1030 1031 if(i<7){ 1032 1033 i++; 1034 1035 1036 delay(400); 1037 1038 lcd.setCursor(6,1); 1039 1040 lcd.print(" 1041 "); 1042 1043 } 1044 1045 lcd.setCursor(6,1); 1046 1047 lcd.print(mySubject[i]); 1048 1049 1050 } 1051 1052 if(bS4==LOW && pos==5){ 1053 1054 EEPROM.write(j+7,i); 1055 1056 1057 lcd.setCursor(0,0); 1058 1059 lcd.print(" *****SAVED**** "); 1060 1061 1062 Serial.print(j+7); 1063 1064 Serial.println(i); 1065 1066 delay(1000); 1067 1068 1069 lcd.clear(); 1070 1071 j++; 1072 1073 } 1074 1075if(bS3==LOW && pos==5){ 1076 1077 1078 lcd.setCursor(0,0); 1079 1080 lcd.print(" *SUB SAVED TUE* "); 1081 1082 1083 delay(1000); 1084 1085 lcd.setCursor(0,1); 1086 1087 lcd.print(" THANK 1088 YOU "); 1089 1090 pos=6; 1091 1092 delay(3000); 1093 1094 lcd.clear(); 1095 1096 1097 break; 1098 1099} 1100 1101 } 1102 1103/*Subject selection for WEDNESDAY*/ 1104 1105while(pos==6){ 1106 1107 1108 bS1 = digitalRead(b1); 1109 1110 bS2 = digitalRead(b2); 1111 1112 bS3 = digitalRead(b3); 1113 1114 1115 bS4 = digitalRead(b4); 1116 1117 lcd.setCursor(0,0); 1118 1119 lcd.print(" 1120 WEDNESDAY SUB "); 1121 1122 if(bS1==LOW && pos==6){ 1123 1124 if(i>0){ 1125 1126 1127 i--; 1128 1129 delay(400); 1130 1131 lcd.setCursor(6,1); 1132 1133 lcd.print(" 1134 "); 1135 1136 } 1137 1138 lcd.setCursor(6,1); 1139 1140 lcd.print(mySubject[i]); 1141 1142 1143 } 1144 1145 if(bS2==LOW && pos==6){ 1146 1147 if(i<7){ 1148 1149 i++; 1150 1151 1152 delay(400); 1153 1154 lcd.setCursor(6,1); 1155 1156 lcd.print(" 1157 "); 1158 1159 } 1160 1161 lcd.setCursor(6,1); 1162 1163 lcd.print(mySubject[i]); 1164 1165 1166 } 1167 1168 if(bS4==LOW && pos==6){ 1169 1170 EEPROM.write(j+7,i); 1171 1172 1173 lcd.setCursor(0,0); 1174 1175 lcd.print(" *****SAVED**** "); 1176 1177 1178 Serial.print(j+7); 1179 1180 Serial.println(i); 1181 1182 delay(1000); 1183 1184 1185 lcd.clear(); 1186 1187 j++; 1188 1189 } 1190 1191if(bS3==LOW && pos==6){ 1192 1193 1194 lcd.setCursor(0,0); 1195 1196 lcd.print(" *SUB SAVED WED* "); 1197 1198 1199 delay(1000); 1200 1201 lcd.setCursor(0,1); 1202 1203 lcd.print(" THANK 1204 YOU "); 1205 1206 pos=7; 1207 1208 delay(3000); 1209 1210 lcd.clear(); 1211 1212 1213 break; 1214 1215} 1216 1217 } 1218 1219 /*Subject selection for THUSDAY*/ 1220 1221while(pos==7){ 1222 1223 1224 bS1 = digitalRead(b1); 1225 1226 bS2 = digitalRead(b2); 1227 1228 bS3 = digitalRead(b3); 1229 1230 1231 bS4 = digitalRead(b4); 1232 1233 lcd.setCursor(0,0); 1234 1235 lcd.print(" 1236 SLT THUSDAY SUB "); 1237 1238 if(bS1==LOW && pos==7){ 1239 1240 if(i>0){ 1241 1242 1243 i--; 1244 1245 delay(400); 1246 1247 lcd.setCursor(6,1); 1248 1249 lcd.print(" 1250 "); 1251 1252 } 1253 1254 lcd.setCursor(6,1); 1255 1256 lcd.print(mySubject[i]); 1257 1258 1259 } 1260 1261 if(bS2==LOW && pos==7){ 1262 1263 if(i<7){ 1264 1265 i++; 1266 1267 1268 delay(400); 1269 1270 lcd.setCursor(6,1); 1271 1272 lcd.print(" 1273 "); 1274 1275 } 1276 1277 lcd.setCursor(6,1); 1278 1279 lcd.print(mySubject[i]); 1280 1281 1282 } 1283 1284 if(bS4==LOW && pos==7){ 1285 1286 EEPROM.write(j+7,i); 1287 1288 1289 lcd.setCursor(0,0); 1290 1291 lcd.print(" *****SAVED**** "); 1292 1293 1294 Serial.print(j+7); 1295 1296 Serial.println(i); 1297 1298 delay(1000); 1299 1300 1301 lcd.clear(); 1302 1303 j++; 1304 1305 } 1306 1307if(bS3==LOW && pos==7){ 1308 1309 1310 lcd.setCursor(0,0); 1311 1312 lcd.print(" *SUB SAVED THU* "); 1313 1314 1315 delay(1000); 1316 1317 lcd.setCursor(0,1); 1318 1319 lcd.print(" THANK 1320 YOU "); 1321 1322 pos=8; 1323 1324 delay(3000); 1325 1326 lcd.clear(); 1327 1328 1329 break; 1330 1331} 1332 1333 } 1334 1335 1336 /*Subject selection for FRIDAY*/ 1337 1338while(pos==8){ 1339 1340 1341 bS1 = digitalRead(b1); 1342 1343 bS2 = digitalRead(b2); 1344 1345 bS3 = digitalRead(b3); 1346 1347 1348 bS4 = digitalRead(b4); 1349 1350 lcd.setCursor(0,0); 1351 1352 lcd.print(" 1353 SLT FRIDAY SUB "); 1354 1355 if(bS1==LOW && pos==8){ 1356 1357 if(i>0){ 1358 1359 1360 i--; 1361 1362 delay(400); 1363 1364 lcd.setCursor(6,1); 1365 1366 lcd.print(" 1367 "); 1368 1369 } 1370 1371 lcd.setCursor(6,1); 1372 1373 lcd.print(mySubject[i]); 1374 1375 1376 } 1377 1378 if(bS2==LOW && pos==8){ 1379 1380 if(i<7){ 1381 1382 i++; 1383 1384 1385 delay(400); 1386 1387 lcd.setCursor(6,1); 1388 1389 lcd.print(" 1390 "); 1391 1392 } 1393 1394 lcd.setCursor(6,1); 1395 1396 lcd.print(mySubject[i]); 1397 1398 1399 } 1400 1401 if(bS4==LOW && pos==8){ 1402 1403 EEPROM.write(j+7,i); 1404 1405 1406 lcd.setCursor(0,0); 1407 1408 lcd.print(" *****SAVED**** "); 1409 1410 1411 Serial.print(j+7); 1412 1413 Serial.println(i); 1414 1415 delay(1000); 1416 1417 1418 lcd.clear(); 1419 1420 j++; 1421 1422 } 1423 1424if(bS3==LOW && pos==8){ 1425 1426 1427 lcd.setCursor(0,0); 1428 1429 lcd.print(" *SUB SAVED FRI* "); 1430 1431 1432 delay(1000); 1433 1434 lcd.setCursor(0,1); 1435 1436 lcd.print(" THANK 1437 YOU "); 1438 1439 pos=9; 1440 1441 delay(3000); 1442 1443 lcd.clear(); 1444 1445 1446 break; 1447 1448} 1449 1450 } 1451 1452 /*Subject selection for SATURDAY*/ 1453 1454while(pos==9){ 1455 1456 1457 bS1 = digitalRead(b1); 1458 1459 bS2 = digitalRead(b2); 1460 1461 bS3 = digitalRead(b3); 1462 1463 1464 bS4 = digitalRead(b4); 1465 1466 lcd.setCursor(0,0); 1467 1468 lcd.print("SLT 1469 SATURDAY SUB "); 1470 1471 if(bS1==LOW && pos==9){ 1472 1473 if(i>0){ 1474 1475 1476 i--; 1477 1478 delay(400); 1479 1480 lcd.setCursor(6,1); 1481 1482 lcd.print(" 1483 "); 1484 1485 } 1486 1487 lcd.setCursor(6,1); 1488 1489 lcd.print(mySubject[i]); 1490 1491 1492 } 1493 1494 if(bS2==LOW && pos==9){ 1495 1496 if(i<7){ 1497 1498 i++; 1499 1500 1501 delay(400); 1502 1503 lcd.setCursor(6,1); 1504 1505 lcd.print(" 1506 "); 1507 1508 } 1509 1510 lcd.setCursor(6,1); 1511 1512 lcd.print(mySubject[i]); 1513 1514 1515 } 1516 1517 if(bS4==LOW && pos==9){ 1518 1519 EEPROM.write(j+7,i); 1520 1521 1522 lcd.setCursor(0,0); 1523 1524 lcd.print(" *****SAVED**** "); 1525 1526 1527 Serial.print(j+7); 1528 1529 Serial.println(i); 1530 1531 delay(1000); 1532 1533 1534 lcd.clear(); 1535 1536 j++; 1537 1538 } 1539 1540if(bS3==LOW && pos==9){ 1541 1542 1543 lcd.setCursor(0,0); 1544 1545 lcd.print(" *SUB SAVED SAT* "); 1546 1547 1548 delay(1000); 1549 1550 lcd.setCursor(0,1); 1551 1552 lcd.print(" THANK 1553 YOU "); 1554 1555 pos=30; 1556 1557 delay(3000); 1558 1559 lcd.clear(); 1560 1561 1562 break; 1563 1564} 1565 1566 } 1567 1568 1569 1570 /*READING ALL THE DATA FROM 1571 THE INTERNAL EEPROM*/ 1572 1573 starttime = EEPROM.read(0); 1574 1575 endtime 1576 = EEPROM.read(1); 1577 1578 break1 = EEPROM.read(2); 1579 1580 break2 = EEPROM.read(3); 1581 1582 1583 hoursE = EEPROM.read(4);//Period time delay 1584 1585 int totalbreak=break1+ break2; 1586 1587 1588 //totaltime=((endtime-starttime)*10 - totalbreak); 1589 1590 totaltime=((endtime-starttime)*60-totalbreak); 1591 1592 1593 periodtime=totaltime/5; 1594 1595 EEPROM.write(4,periodtime); 1596 1597 Serial.println(EEPROM.read(4)); 1598 1599 1600 pos=30; 1601 1602} 1603 1604 while(pos==30){ 1605 1606 DateTime now =rtc.now(); 1607 1608 1609 hoursH=EEPROM.read(0);//start time in hour 1610 1611 newHour = now.hour(); 1612 1613 1614 newTime = now.minute(); 1615 1616//if(newHour == hoursH && newTime == 0){ 1617 1618 1619 if(newHour == hoursH && newTime <= 60){ 1620 1621 prevTime=now.minute(); 1622 1623 1624 lcd.setCursor(0,0); 1625 1626 lcd.print(" CLASS STARTED "); 1627 1628 lcd.setCursor(0,1); 1629 1630 1631 lcd.print(" "); 1632 1633 delay(3000); 1634 1635 lcd.clear(); 1636 1637 1638 while(1){ 1639 1640 matchDAY(); 1641 1642 } 1643 1644} 1645 1646else{ 1647 1648 1649 lcd.setCursor(0,0); 1650 1651 lcd.print(" Waiting for... "); 1652 1653 lcd.setCursor(5,1); 1654 1655 1656 printDigits2(hoursH); 1657 1658 lcd.setCursor(8,1); 1659 1660 lcd.print("O' Clock");} 1661 1662 1663 } 1664 1665} 1666 1667 1668 1669void matchDAY(){ 1670 1671 DateTime now =rtc.now(); 1672 1673 1674 //Monday subject display 1675 1676while(now.dayOfTheWeek()== 1){ 1677 1678 currentTIME(); 1679 1680 1681 matchTIM(); 1682 1683 1684 1685 value = EEPROM.read(monA); 1686 1687 ALLDays(now.dayOfTheWeek()); 1688 1689 1690 lcd.setCursor(0,0); 1691 1692 lcd.print(mySubject[value]); 1693 1694 if(noPeriod==2 1695 && breakR==0){ 1696 1697 brk1=EEPROM.read(2); 1698 1699 lcd.setCursor(0,0); 1700 1701 1702 lcd.print("***BREAK TIME***"); 1703 1704 while(1){ 1705 1706 currentTIME(); 1707 1708 1709 if(newTime == prevTime + brk1){ 1710 1711 prevTime=prevTime+brk1; 1712 1713 1714 Serial.print("Break1"); 1715 1716 Serial.println(prevTime); 1717 1718 1719 noPeriod=0; 1720 1721 breakR=1; 1722 1723 lcd.clear(); 1724 1725 1726 break; 1727 1728 } 1729 1730 } 1731 1732 } 1733 1734 1735 if(noPeriod==1 && breakR==2){ 1736 1737 breakR=0; 1738 1739 lcd.clear(); 1740 1741 1742 endsession(); 1743 1744 while(1){ 1745 1746 //End of the session 1747 1748 1749 } 1750 1751 } 1752 1753 //hoursE 1754 1755 if(noPeriod==2 && breakR==1){ 1756 1757 1758 brk2=EEPROM.read(3);//time delay 1759 1760 lcd.setCursor(0,0); 1761 1762 lcd.print("***BREAK 1763 TIME***"); 1764 1765 while(1){ 1766 1767 currentTIME(); 1768 1769 lcd.setCursor(11,0); 1770 1771 1772 printDigits2(newTime); 1773 1774 printDigits2(now.second()); 1775 1776 if(newTime== 1777 prevTime + brk2){ 1778 1779 prevTime=prevTime+brk2; 1780 1781 Serial.print("Break2"); 1782 1783 1784 Serial.println(prevTime); 1785 1786 noPeriod=0; 1787 1788 breakR=2; 1789 1790 1791 lcd.clear(); 1792 1793 break; 1794 1795 } 1796 1797 1798 } 1799 1800 } 1801 1802 else{ 1803 1804 1805 1806 nextSUB = EEPROM.read(monA+1); 1807 1808 1809 ALLSubjects(9); 1810 1811 if(noPeriod == 0 && breakR == 2) 1812 1813 ALLSubjects(8); 1814 1815 1816 else 1817 1818 ALLSubjects(nextSUB); 1819 1820 } 1821 1822 } 1823 1824 1825 // Tuesday subject display 1826 1827while(now.dayOfTheWeek()== 2){ 1828 1829 currentTIME(); 1830 1831 1832 matchTIM(); 1833 1834 1835 1836 value = EEPROM.read(tueA); 1837 1838 ALLDays(now.dayOfTheWeek()); 1839 1840 1841 lcd.setCursor(0,0); 1842 1843 lcd.print(mySubject[value]); 1844 1845 if(noPeriod==2 1846 && breakR==0){ 1847 1848 brk1=EEPROM.read(2); 1849 1850 lcd.setCursor(0,0); 1851 1852 1853 lcd.print("***BREAK TIME***"); 1854 1855 while(1){ 1856 1857 currentTIME(); 1858 1859 1860 if(newTime== prevTime + brk1){ 1861 1862 prevTime=prevTime+brk1; 1863 1864 1865 Serial.print("Break1"); 1866 1867 Serial.println(prevTime); 1868 1869 1870 noPeriod=0; 1871 1872 breakR=1; 1873 1874 lcd.clear(); 1875 1876 1877 break; 1878 1879 } 1880 1881 } 1882 1883 } 1884 1885 1886 if(noPeriod==1 && breakR==2){ 1887 1888 breakR=0; 1889 1890 endsession(); 1891 1892 1893 while(1){ 1894 1895 //End of the session 1896 1897 } 1898 1899 1900 } 1901 1902 if(noPeriod==2 && breakR==1){ 1903 1904 brk2=EEPROM.read(3);//time 1905 delay 1906 1907 lcd.setCursor(0,0); 1908 1909 lcd.print("***BREAK TIME***"); 1910 1911 1912 while(1){ 1913 1914 currentTIME(); 1915 1916 if(newTime== prevTime + brk2){ 1917 1918 1919 prevTime=prevTime+brk2; 1920 1921 Serial.print("Break2"); 1922 1923 Serial.println(prevTime); 1924 1925 1926 noPeriod=0; 1927 1928 breakR=2; 1929 1930 lcd.clear(); 1931 1932 1933 break; 1934 1935 } 1936 1937 } 1938 1939 } 1940 1941 1942 else{ 1943 1944 nextSUB = EEPROM.read(tueA+1); 1945 1946 ALLSubjects(9); 1947 1948 1949 if(noPeriod == 0 && breakR == 2) 1950 1951 ALLSubjects(8); 1952 1953 1954 else 1955 1956 ALLSubjects(nextSUB); 1957 1958 } 1959 1960 } 1961 1962 1963 1964 1965//Wednesday subject display 1966 1967while(now.dayOfTheWeek()== 3){ 1968 1969 1970 currentTIME(); 1971 1972 matchTIM(); 1973 1974 value = EEPROM.read(wedA); 1975 1976 1977 ALLDays(now.dayOfTheWeek()); 1978 1979 lcd.setCursor(0,0); 1980 1981 lcd.print(mySubject[value]); 1982 1983 1984 if(noPeriod==2 && breakR==0){ 1985 1986 brk1=EEPROM.read(2); 1987 1988 lcd.setCursor(0,0); 1989 1990 1991 lcd.print("***BREAK TIME***"); 1992 1993 while(1){ 1994 1995 currentTIME(); 1996 1997 1998 if(newTime== prevTime + brk1){ 1999 2000 prevTime=prevTime+brk1; 2001 2002 2003 Serial.print("Break1"); 2004 2005 Serial.println(prevTime); 2006 2007 2008 noPeriod=0; 2009 2010 breakR=1; 2011 2012 lcd.clear(); 2013 2014 2015 break; 2016 2017 } 2018 2019 } 2020 2021 } 2022 2023 2024 if(noPeriod==1 && breakR==2){ 2025 2026 breakR=0; 2027 2028 endsession(); 2029 2030 2031 while(1){ 2032 2033 //End of the session 2034 2035 } 2036 2037 2038 } 2039 2040 if(noPeriod==2 && breakR==1){ 2041 2042 brk2=EEPROM.read(3);//time 2043 delay 2044 2045 lcd.setCursor(0,0); 2046 2047 lcd.print("***BREAK TIME***"); 2048 2049 2050 while(1){ 2051 2052 currentTIME(); 2053 2054 if(newTime== prevTime + brk2){ 2055 2056 2057 prevTime=prevTime+brk2; 2058 2059 Serial.print("Break2"); 2060 2061 Serial.println(prevTime); 2062 2063 2064 noPeriod=0; 2065 2066 breakR=2; 2067 2068 lcd.clear(); 2069 2070 2071 break; 2072 2073 } 2074 2075 } 2076 2077 } 2078 2079 2080 else{ 2081 2082 nextSUB = EEPROM.read(wedA+1); 2083 2084 ALLSubjects(9); 2085 2086 2087 if(noPeriod == 0 && breakR == 2) 2088 2089 ALLSubjects(8); 2090 2091 2092 else 2093 2094 ALLSubjects(nextSUB); 2095 2096 } 2097 2098 } 2099 2100 2101// 2102 Thusday subject display 2103 2104while(now.dayOfTheWeek()== 4){ 2105 2106 currentTIME(); 2107 2108 2109 matchTIM(); 2110 2111 value = EEPROM.read(thuA); 2112 2113 ALLDays(now.dayOfTheWeek()); 2114 2115 2116 lcd.setCursor(0,0); 2117 2118 lcd.print(mySubject[value]); 2119 2120 if(noPeriod==2 2121 && breakR==0){ 2122 2123 brk1=EEPROM.read(2); 2124 2125 lcd.setCursor(0,0); 2126 2127 2128 lcd.print("***BREAK TIME***"); 2129 2130 while(1){ 2131 2132 currentTIME(); 2133 2134 2135 if(newTime== prevTime + brk1){ 2136 2137 prevTime=prevTime+brk1; 2138 2139 2140 Serial.print("Break1"); 2141 2142 Serial.println(prevTime); 2143 2144 2145 noPeriod=0; 2146 2147 breakR=1; 2148 2149 lcd.clear(); 2150 2151 2152 break; 2153 2154 } 2155 2156 } 2157 2158 } 2159 2160 2161 if(noPeriod==1 && breakR==2){ 2162 2163 breakR=0; 2164 2165 endsession(); 2166 2167 2168 while(1){ 2169 2170 //End of the session 2171 2172 } 2173 2174 2175 } 2176 2177 if(noPeriod==2 && breakR==1){ 2178 2179 brk2=EEPROM.read(3);//time 2180 delay 2181 2182 lcd.setCursor(0,0); 2183 2184 lcd.print("***BREAK TIME***"); 2185 2186 2187 while(1){ 2188 2189 currentTIME(); 2190 2191 if(newTime== prevTime + brk2){ 2192 2193 2194 prevTime=prevTime+brk2; 2195 2196 Serial.print("Break2"); 2197 2198 Serial.println(prevTime); 2199 2200 2201 noPeriod=0; 2202 2203 breakR=2; 2204 2205 lcd.clear(); 2206 2207 2208 break; 2209 2210 } 2211 2212 } 2213 2214 } 2215 2216 2217 else{ 2218 2219 nextSUB = EEPROM.read(thuA+1); 2220 2221 ALLSubjects(9); 2222 2223 2224 if(noPeriod == 0 && breakR == 2) 2225 2226 ALLSubjects(8); 2227 2228 2229 else 2230 2231 ALLSubjects(nextSUB); 2232 2233 } 2234 2235 } 2236 2237 2238 2239 2240 2241 //Friday subject display 2242 2243while(now.dayOfTheWeek()== 5){ 2244 2245 2246 currentTIME(); 2247 2248 matchTIM(); 2249 2250 value = EEPROM.read(friA); 2251 2252 2253 ALLDays(now.dayOfTheWeek()); 2254 2255 lcd.setCursor(0,0); 2256 2257 lcd.print(mySubject[value]); 2258 2259 2260 if(noPeriod==2 && breakR==0){ 2261 2262 brk1=EEPROM.read(2); 2263 2264 lcd.setCursor(0,0); 2265 2266 2267 lcd.print("***BREAK TIME***"); 2268 2269 while(1){ 2270 2271 currentTIME(); 2272 2273 2274 if(newTime== prevTime + brk1){ 2275 2276 prevTime=prevTime+brk1; 2277 2278 2279 Serial.print("Break1"); 2280 2281 Serial.println(prevTime); 2282 2283 2284 noPeriod=0; 2285 2286 breakR=1; 2287 2288 lcd.clear(); 2289 2290 2291 break; 2292 2293 } 2294 2295 } 2296 2297 } 2298 2299 2300 if(noPeriod==1 && breakR==2){ 2301 2302 breakR=0; 2303 2304 endsession(); 2305 2306 2307 while(1){ 2308 2309 //End of the session 2310 2311 } 2312 2313 2314 } 2315 2316 if(noPeriod==2 && breakR==1){ 2317 2318 brk2=EEPROM.read(3);//time 2319 delay 2320 2321 lcd.setCursor(0,0); 2322 2323 lcd.print("***BREAK TIME***"); 2324 2325 2326 while(1){ 2327 2328 currentTIME(); 2329 2330 if(newTime== prevTime + brk2){ 2331 2332 2333 prevTime=prevTime+brk2; 2334 2335 Serial.print("Break2"); 2336 2337 Serial.println(prevTime); 2338 2339 2340 noPeriod=0; 2341 2342 breakR=2; 2343 2344 lcd.clear(); 2345 2346 2347 break; 2348 2349 } 2350 2351 } 2352 2353 } 2354 2355 2356 else{ 2357 2358 nextSUB = EEPROM.read(friA+1); 2359 2360 ALLSubjects(9); 2361 2362 2363 if(noPeriod == 0 && breakR == 2) 2364 2365 ALLSubjects(8); 2366 2367 2368 else 2369 2370 ALLSubjects(nextSUB); 2371 2372 } 2373 2374 } 2375 2376 2377 2378 2379 2380 //Saturday subject display 2381 2382while(now.dayOfTheWeek()== 6){ 2383 2384 2385 currentTIME(); 2386 2387 matchTIM(); 2388 2389 value = EEPROM.read(satA); 2390 2391 2392 ALLDays(now.dayOfTheWeek()); 2393 2394 lcd.setCursor(0,0); 2395 2396 lcd.print(mySubject[value]); 2397 2398 2399 if(noPeriod==2 && breakR==0){ 2400 2401 brk1=EEPROM.read(2); 2402 2403 lcd.setCursor(0,0); 2404 2405 2406 lcd.print("***BREAK TIME***"); 2407 2408 while(1){ 2409 2410 currentTIME(); 2411 2412 2413 if(newTime== prevTime + brk1){ 2414 2415 prevTime=prevTime+brk1; 2416 2417 2418 Serial.print("Break1"); 2419 2420 Serial.println(prevTime); 2421 2422 2423 noPeriod=0; 2424 2425 breakR=1; 2426 2427 lcd.clear(); 2428 2429 2430 break; 2431 2432 } 2433 2434 } 2435 2436 } 2437 2438 2439 if(noPeriod==1 && breakR==2){ 2440 2441 breakR=0; 2442 2443 endsession(); 2444 2445 2446 while(1){ 2447 2448 //End of the session 2449 2450 } 2451 2452 2453 } 2454 2455 if(noPeriod==2 && breakR==1){ 2456 2457 brk2=EEPROM.read(3);//time 2458 delay 2459 2460 lcd.setCursor(0,0); 2461 2462 lcd.print("***BREAK TIME***"); 2463 2464 2465 while(1){ 2466 2467 currentTIME(); 2468 2469 if(newTime== prevTime + brk2){ 2470 2471 2472 prevTime=prevTime+brk2; 2473 2474 Serial.print("Break2"); 2475 2476 Serial.println(prevTime); 2477 2478 2479 noPeriod=0; 2480 2481 breakR=2; 2482 2483 lcd.clear(); 2484 2485 2486 break; 2487 2488 } 2489 2490 } 2491 2492 } 2493 2494 2495 else{ 2496 2497 nextSUB = EEPROM.read(satA+1); 2498 2499 ALLSubjects(9); 2500 2501 2502 if(noPeriod == 0 && breakR == 2) 2503 2504 ALLSubjects(8); 2505 2506 2507 else 2508 2509 ALLSubjects(nextSUB); 2510 2511 } 2512 2513 } 2514 2515} 2516 2517 2518 2519 2520void 2521 currentTIME(){ 2522 2523 lcd.setCursor(6,1); 2524 2525 lcd.print(" "); 2526 2527 DateTime 2528 now = rtc.now(); 2529 2530 lcd.setCursor(8,1); 2531 2532 printDigits2(HOUR=now.hour()); 2533 2534 2535 lcd.print(":"); 2536 2537 newHour=now.hour(); 2538 2539 printDigits2(MINUT=now.minute()); 2540 2541 2542 lcd.print(":"); 2543 2544 newTime = now.minute(); 2545 2546 printDigits2(SECOND=now.second()); 2547 2548 2549 2550 delay(800); 2551 2552 currentDAY(); 2553 2554 delay(800); 2555 2556} 2557 2558 2559void currentDAY(){ 2560 2561 2562 DateTime now = rtc.now(); 2563 2564 lcd.setCursor(6,1); 2565 2566 printDigits2(now.day()); 2567 2568 2569 lcd.print("/"); 2570 2571 printDigits2(now.month()); 2572 2573 lcd.print("/"); 2574 2575 2576 lcd.print(now.year(),DEC); 2577 2578 2579} 2580 2581 2582 2583void matchTIM(){ 2584 2585 2586 DateTime now =rtc.now(); 2587 2588 int tempTime = prevTime + hoursE; 2589 2590 if(tempTime 2591 >=60){ 2592 2593 tempTime = tempTime - 60; 2594 2595 } 2596 2597 else 2598 2599 tempTime 2600 = prevTime + hoursE; 2601 2602if(newTime == tempTime){ 2603 2604 prevTime=now.minute(); 2605 2606 2607 Serial.print("MatchTime"); 2608 2609 Serial.println(prevTime); 2610 2611 if(now.dayOfTheWeek()==1){ 2612 2613 2614 digitalWrite( buzzer, HIGH ); 2615 2616 delay(3000); 2617 2618 digitalWrite( 2619 buzzer, LOW ); 2620 2621 monA++; 2622 2623 noPeriod++; 2624 2625 lcd.setCursor(0,0); 2626 2627 2628 lcd.print(" "); 2629 2630 } 2631 2632 if(now.dayOfTheWeek()==2){ 2633 2634 2635 digitalWrite( buzzer, HIGH ); 2636 2637 delay(3000); 2638 2639 digitalWrite( 2640 buzzer, LOW ); 2641 2642 tueA++; 2643 2644 noPeriod++; 2645 2646 lcd.setCursor(0,0); 2647 2648 2649 lcd.print(" "); 2650 2651 } 2652 2653 if(now.dayOfTheWeek()==3){ 2654 2655 2656 digitalWrite( buzzer, HIGH ); 2657 2658 delay(3000); 2659 2660 digitalWrite( 2661 buzzer, LOW ); 2662 2663 wedA++; 2664 2665 noPeriod++; 2666 2667 lcd.setCursor(0,0); 2668 2669 2670 lcd.print(" "); 2671 2672 } 2673 2674 if(now.dayOfTheWeek()==4){ 2675 2676 2677 digitalWrite( buzzer, HIGH ); 2678 2679 delay(3000); 2680 2681 digitalWrite( 2682 buzzer, LOW ); 2683 2684 thuA++; 2685 2686 noPeriod++; 2687 2688 lcd.setCursor(0,0); 2689 2690 2691 lcd.print(" "); 2692 2693 } 2694 2695 if(now.dayOfTheWeek()==5){ 2696 2697 2698 digitalWrite( buzzer, HIGH ); 2699 2700 delay(3000); 2701 2702 digitalWrite( 2703 buzzer, LOW ); 2704 2705 friA++; 2706 2707 noPeriod++; 2708 2709 lcd.setCursor(0,0); 2710 2711 2712 lcd.print(" "); 2713 2714 } 2715 2716 if(now.dayOfTheWeek()==6){ 2717 2718 2719 digitalWrite( buzzer, HIGH ); 2720 2721 delay(3000); 2722 2723 digitalWrite( 2724 buzzer, LOW ); 2725 2726 satA++; 2727 2728 noPeriod++; 2729 2730 lcd.setCursor(0,0); 2731 2732 2733 lcd.print(" "); 2734 2735 } 2736 2737} 2738 2739} 2740 2741 2742//this 2743 void function is really useful; it adds a "0" to the beginning of the number, 2744 2745 2746//so that 5 minutes is displayed as "05", rather than "5 " 2747 2748void 2749 printDigits2(int digits) 2750 2751{ 2752 2753 if(digits < 10) 2754 2755 { 2756 2757 2758 lcd.print("0"); 2759 2760 lcd.print(digits); 2761 2762 } 2763 2764 else 2765 2766 2767 { 2768 2769 lcd.print(digits); 2770 2771 } 2772 2773} 2774 2775 2776 2777//char* mySubject[]={"MATHS", 2778 "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"}; 2779 2780void ALLSubjects(int 2781 sub) 2782 2783{ 2784 2785 switch(sub) 2786 2787 { 2788 2789 case 0: 2790 2791 lcd.createChar(1,Malpha); 2792 2793 2794 lcd.createChar(2,Aalpha); 2795 2796 lcd.createChar(3,Talpha); 2797 2798 2799 lcd.createChar(4,Halpha); 2800 2801 lcd.setCursor(0,1); 2802 2803 2804 lcd.write(1); 2805 2806 lcd.setCursor(1,1); 2807 2808 lcd.write(2); 2809 2810 2811 lcd.setCursor(2,1); 2812 2813 lcd.write(3); 2814 2815 lcd.setCursor(3,1); 2816 2817 2818 lcd.write(4);break; 2819 2820 case 1: 2821 2822 lcd.setCursor(0,1); 2823 2824 2825 lcd.write(" "); 2826 2827 delay(50); 2828 2829 lcd.createChar(1,Ealpha); 2830 2831 2832 lcd.createChar(2,Nalpha); 2833 2834 lcd.createChar(3,Galpha); 2835 2836 2837 lcd.setCursor(0,1); 2838 2839 lcd.write(1); 2840 2841 lcd.setCursor(1,1); 2842 2843 2844 lcd.write(2); 2845 2846 lcd.setCursor(2,1); 2847 2848 lcd.write(3);break; 2849 2850 2851 //char* mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"}; 2852 2853 2854 case 2: 2855 2856 lcd.setCursor(0,1); 2857 2858 lcd.write(" 2859 "); 2860 2861 delay(50); 2862 2863 lcd.createChar(1,Balpha); 2864 2865 2866 lcd.createChar(2,Ialpha); 2867 2868 lcd.createChar(3,Oalpha); 2869 2870 2871 lcd.setCursor(0,1); 2872 2873 lcd.write(1); 2874 2875 lcd.setCursor(1,1); 2876 2877 2878 lcd.write(2); 2879 2880 lcd.setCursor(2,1); 2881 2882 lcd.write(3);break; 2883 2884 2885 case 3: 2886 2887 lcd.setCursor(0,1); 2888 2889 lcd.write(" "); 2890 2891 2892 delay(50); 2893 2894 lcd.createChar(1,Palpha); 2895 2896 lcd.createChar(2,Halpha); 2897 2898 2899 lcd.createChar(3,Yalpha); 2900 2901 lcd.setCursor(0,1); 2902 2903 2904 lcd.write(1); 2905 2906 lcd.setCursor(1,1); 2907 2908 lcd.write(2); 2909 2910 2911 lcd.setCursor(2,1); 2912 2913 lcd.write(3);break; 2914 2915 //char* 2916 mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"}; 2917 2918 2919 case 4: 2920 2921 lcd.setCursor(0,1); 2922 2923 lcd.write(" 2924 "); 2925 2926 delay(50); 2927 2928 lcd.createChar(1,Calpha); 2929 2930 2931 lcd.createChar(2,Halpha); 2932 2933 lcd.createChar(3,Ealpha); 2934 2935 2936 lcd.createChar(4,Malpha); 2937 2938 lcd.setCursor(0,1); 2939 2940 2941 lcd.write(1); 2942 2943 lcd.setCursor(1,1); 2944 2945 lcd.write(2); 2946 2947 2948 lcd.setCursor(2,1); 2949 2950 lcd.write(3); 2951 2952 lcd.setCursor(3,1); 2953 2954 2955 lcd.write(4);break; 2956 2957 2958 2959 case 5: 2960 2961 lcd.createChar(1,Ialpha); 2962 2963 2964 lcd.createChar(2,Talpha); 2965 2966 lcd.setCursor(0,1); 2967 2968 2969 lcd.write(1); 2970 2971 lcd.setCursor(1,1); 2972 2973 lcd.write(2);break; 2974 2975 2976 2977 2978 case 6: 2979 2980 lcd.setCursor(0,1); 2981 2982 lcd.write(" 2983 "); 2984 2985 delay(50); 2986 2987 lcd.createChar(1,Halpha); 2988 2989 2990 lcd.createChar(2,Ialpha); 2991 2992 lcd.createChar(3,Salpha); 2993 2994 2995 lcd.createChar(4,Talpha); 2996 2997 lcd.setCursor(0,1); 2998 2999 3000 lcd.write(1); 3001 3002 lcd.setCursor(1,1); 3003 3004 lcd.write(2); 3005 3006 3007 lcd.setCursor(2,1); 3008 3009 lcd.write(3); 3010 3011 lcd.setCursor(3,1); 3012 3013 3014 lcd.write(4);break; 3015 3016 //char* mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT 3017 LAB","HIST","GEO"}; 3018 3019 case 7: 3020 3021 lcd.setCursor(0,1); 3022 3023 3024 lcd.write(" "); 3025 3026 delay(50); 3027 3028 lcd.createChar(1,Galpha); 3029 3030 3031 lcd.createChar(2,Ealpha); 3032 3033 lcd.createChar(3,Oalpha); 3034 3035 3036 lcd.setCursor(0,1); 3037 3038 lcd.write(1); 3039 3040 lcd.setCursor(1,1); 3041 3042 3043 lcd.write(2); 3044 3045 lcd.setCursor(2,1); 3046 3047 lcd.write(3);break; 3048 3049 3050 case 8: 3051 3052 lcd.setCursor(0,1); 3053 3054 lcd.write(" "); 3055 3056 3057 delay(50); 3058 3059 lcd.createChar(1,Ealpha); 3060 3061 lcd.createChar(2,Nalpha); 3062 3063 3064 lcd.createChar(3,Dalpha); 3065 3066 lcd.setCursor(0,1); 3067 3068 3069 lcd.write(1); 3070 3071 lcd.setCursor(1,1); 3072 3073 lcd.write(2); 3074 3075 3076 lcd.setCursor(2,1); 3077 3078 lcd.write(3);break; 3079 3080 3081 case 9: 3082 3083 lcd.createChar(8,next); 3084 3085 lcd.setCursor(5,1); 3086 3087 3088 lcd.write(8); 3089 3090 delay(1000); 3091 3092 lcd.setCursor(5,1); 3093 3094 3095 lcd.write(" "); 3096 3097 delay(1000);break; 3098 3099 default:break; 3100 3101 3102 } 3103 3104} 3105 3106 3107void ALLDays(int dey) 3108 3109{ 3110 3111 switch(dey) 3112 3113 3114 { 3115 3116 case 0://sun 3117 3118 lcd.createChar(5,Salpha); 3119 3120 lcd.createChar(6,Ualpha); 3121 3122 3123 lcd.createChar(7,Nalpha); 3124 3125 lcd.setCursor(7,0); 3126 3127 3128 lcd.write(5); 3129 3130 lcd.setCursor(8,0); 3131 3132 lcd.write(6); 3133 3134 3135 lcd.setCursor(9,0); 3136 3137 lcd.write(7);var=1;break; 3138 3139 3140 case 1://mon 3141 3142 lcd.createChar(5,Malpha); 3143 3144 lcd.createChar(6,Oalpha); 3145 3146 3147 lcd.createChar(7,Nalpha); 3148 3149 lcd.setCursor(7,0); 3150 3151 3152 lcd.write(5); 3153 3154 lcd.setCursor(8,0); 3155 3156 lcd.write(6); 3157 3158 3159 lcd.setCursor(9,0); 3160 3161 lcd.write(7);var=2;break; 3162 3163 3164 case 2://tue 3165 3166 lcd.createChar(5,Talpha); 3167 3168 lcd.createChar(6,Ualpha); 3169 3170 3171 lcd.createChar(7,Ealpha); 3172 3173 lcd.setCursor(7,0); 3174 3175 3176 lcd.write(5); 3177 3178 lcd.setCursor(8,0); 3179 3180 lcd.write(6); 3181 3182 3183 lcd.setCursor(9,0); 3184 3185 lcd.write(7);var=3;break; 3186 3187 3188 3189 3190 case 3://wed 3191 3192 lcd.createChar(5,Walpha); 3193 3194 3195 lcd.createChar(6,Ealpha); 3196 3197 lcd.createChar(7,Dalpha); 3198 3199 3200 lcd.setCursor(7,0); 3201 3202 lcd.write(5); 3203 3204 lcd.setCursor(8,0); 3205 3206 3207 lcd.write(6); 3208 3209 lcd.setCursor(9,0); 3210 3211 lcd.write(7);var=4;break; 3212 3213 3214 case 4://thu 3215 3216 lcd.createChar(5,Talpha); 3217 3218 lcd.createChar(6,Halpha); 3219 3220 3221 lcd.createChar(7,Ualpha); 3222 3223 lcd.setCursor(7,0); 3224 3225 3226 lcd.write(5); 3227 3228 lcd.setCursor(8,0); 3229 3230 lcd.write(6); 3231 3232 3233 lcd.setCursor(9,0); 3234 3235 lcd.write(7);var=5;break; 3236 3237 3238 case 5://fri 3239 3240 lcd.createChar(5,Falpha); 3241 3242 lcd.createChar(6,Ralpha); 3243 3244 3245 lcd.createChar(7,Ialpha); 3246 3247 lcd.setCursor(7,0); 3248 3249 3250 lcd.write(5); 3251 3252 lcd.setCursor(8,0); 3253 3254 lcd.write(6); 3255 3256 3257 lcd.setCursor(9,0); 3258 3259 lcd.write(7);var=6;break; 3260 3261 3262 case 6://sat 3263 3264 lcd.createChar(5,Salpha); 3265 3266 lcd.createChar(6,Aalpha); 3267 3268 3269 lcd.createChar(7,Talpha); 3270 3271 lcd.setCursor(7,0); 3272 3273 3274 lcd.write(5); 3275 3276 lcd.setCursor(8,0); 3277 3278 lcd.write(6); 3279 3280 3281 lcd.setCursor(9,0); 3282 3283 lcd.write(7);var=7;break; 3284 3285 3286 default:break; 3287 3288 } 3289 3290} 3291 3292 3293void endsession(){ 3294 3295 3296 lcd.setCursor(0,0); 3297 3298 lcd.print(" Session End "); 3299 3300 lcd.setCursor(0,1); 3301 3302 3303 lcd.print(" Good Luck :) "); 3304 3305 delay(3000); 3306 3307}
Downloadable files
Arduino based Automatic School Bell System
Arduino based Automatic School Bell System
Arduino based Automatic School Bell System
Arduino based Automatic School Bell System
Comments
Only logged in users can leave comments