Kamis, 25 Maret 2021

Sketch Auto Tarhim / Auto Murottal v6 (AB Led Auto Murottal Masjid Sei. Kakap)

Sketch AB Led Auto Murottal v (24 Maret 2021):

   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
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
//----------------------------------------Include the NodeMCU ESP8266 Library---------------------------------------------------------------------------------------------------------------//
//----------------------------------------see here: https://www.youtube.com/watch?v=8jMr94B8iN0 to add NodeMCU ESP8266 library and board
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ESP8266WebServer.h>

#include <Timer.h>

#include <PrayerTimes.h>

//RTC>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//#include <DS3231.h>
#include <RTClib.h>
#include <Wire.h>
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#include <EEPROM.h>
#include "DFRobotDFPlayerMini.h"
#include <SoftwareSerial.h>
#define PIN_BUSY D5
#define _RELAY D6
//#define MICSIG D7
//#define LEDMIC 15

#define DS3231_I2C_ADDRESS 0x68

DFRobotDFPlayerMini ABLedDFPlayer;
void printDetail(uint8_t type, int value);

SoftwareSerial mp3Serial(D1, D2); // RX, TX Arduino
ESP8266WebServer server;  //--> Server
WiFiUDP udp;
IPAddress DestinationIP(192,168,4,3); //--> If the Destination IP is 192,168,4,2 then you can use the Destination 192,168,4,2 or 192,168,4,255
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
unsigned int localPort = 2000;

Timer tMain;  //, tStandBy, tHold;

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//Parameter2 simpan di EEPROM / FlashMemory
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

String ssidSaved;   //= "ABLed_NodeMCU_ESP8266";
String passwordSaved; // = "goodluck";
//----------------------------------------------------


int ihti = 0; //2;
int durasiAdzan = 30000;  //3 * 60000;  //3 menit
// PrayerTimes
double times[sizeof(TimeName)/sizeof(char*)];
int idFileMur = 0;

int flagTes2 = 1;


char packetBuffer[50];
String inString;
char replyBuffer[50];
String strCon;
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  int oPM;  // = EEPROM.read(98);  //Cek opsi putar murottal. 
            //0 = manual / bebas jam kapan saja, 1 = beberapa menit sebelum adzan

  String jamMenitDetikMurottalSatu;
  String jamMenitDetikMurottalDua;
  String jamMenitDetikMurottalTiga;
  String jamMenitDetikMurottalEmpat;  
  String jamMenitDetikMurottalDefault;
  int durasiMurottalSatu;
  int durasiMurottalDua;
  int durasiMurottalTiga;
  int durasiMurottalEmpat;
  int durasiMurottalDefaultOpsiBebas;
  
  int selisihMntMurottalShubuh;   //berapa menit sebelum adzan shubuh
  int selisihMntMurottalDhuhur; //berapa menit sebelum adzan dhuhur
  int selisihMntMurottalAshar;  ////berapa menit sebelum adzan ashar
  int selisihMntMurottalMaghrib;  ////berapa menit sebelum adzan maghrib
  int selisihMntMurottalEmpatWktDefault;
  int durasiMurottalShubuh;
  int durasiMurottalDhuhur;
  int durasiMurottalAshar;
  int durasiMurottalMaghrib;
  int durasiMurottalDefaultOpsiTdkBebas;

  int fileMurottalShubuhDanSatu;
  int fileMurottalDhuhurDanDua;
  int fileMurottalAsharDanTiga;
  int fileMurottalMaghribDanEmpat;
  int fileMurottalDefault;

  int jamOnAmpliShubuh;
  int jamOffAmpliShubuh;
  int jamOnAmpliDhuhur;
  int jamOffAmpliDhuhur;
  int jamOnAmpliAshar;
  int jamOffAmpliAshar;
  int jamOnAmpliMaghrib;
  int jamOffAmpliMaghrib;
  int jamOnAmpliIsya;
  int jamOffAmpliIsya;
  int jamStopMurottalShubuh;
  int jamStopMurottalDhuhur;
  int jamStopMurottalAshar;
  int jamStopMurottalMaghrib;
  
  int flagPlayMP3 = 0;
  
  int nadaON = 31;
  int nadaOFF = 32;
/*
  int suaraJam = 33;
  int suaraMenit = 34;
  int suaraDetik = 35;
  int suaraAngka1 = 36;
  int suaraAngka2 = 37;
  int suaraAngka3 = 38;
  int suaraAngka4 = 39;
  int suaraAngka5 = 40;
  int suaraAngka6 = 41;
  int suaraAngka7 = 42;
  int suaraAngka8 = 43;
  int suaraAngka9 = 44;
  int suaraAngka0 = 45;
  int suaraKosong = 46;
  int suaraPuluh = 47;
  int suaraBelas = 48;
  int suaraAngka10 = 49;
  int suaraAngka11 = 50;
  int suaraLewat = 51;
  int suaraWktSdhDiSetKe = 52;
  int aturWaktu = 53;
  int aturTanggal = 54;
  int suaraTglSdhDiSetKe = 55;
  int suaraRibu = 56;
  int suaraRatus = 57;
  int suaraSeratus = 58;
  int suaraSeribu = 59;
*/  
  
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

int volumeSuara;
int flagCekPlayMP3 = 0;
int volumeMP3;
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

//RTCDS3231
//.............................................................................>>>>>>>>>>>>>>>>>>>>>>>>
//DS3231 Clock;
RTC_DS3231 rtc;

byte Year;
byte Month;
byte Date;
byte DoW;
byte Hour;
byte Minute;
byte Second;

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


//----------------------------------------Make a wifi name and password as access point-----------------------------------------------------------------------------------------------------//
//const char* ssid = &ssidSaved;
//const char* password = &passwordSaved;
const char* ssid; // = ssidSaved.c_str();
const char* password; // = passwordSaved.c_str();
//IPAddress ap_local_IP(192,168,3,1);
//IPAddress ap_gateway(192,168,3,254);
//IPAddress ap_subnet(255,255,255,0);
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

void readSSIDnPWD();
void playMP3(int idMurottal);
void writeEEPROM(int addr, char _char);
void writeEEPROM(int addr, String str);
void tampilInfoRTC();
void receive_packet();
void jadwalSholat();
void tampilJadwalSholat();


//-----------------------------------------------------------------------------------------------SETUP--------------------------------------------------------------------------------------//
void setup() {
  // put your setup code here, to run once:

  // Wire / RTC, Start the I2C interface
  Wire.begin(0, 2);   //Setting wire (D3 / GPIO0 untuk SDA, dan D4 / GPIO2 untuk SCL)
  //Wire.begin(5, 4);   //Setting wire (5 untuk SDA dan 4 untuk SCL)
 
  rtc.begin();
  //rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));  //Setting Time
  // Kalian dapat menambahkan bagian dibawah ini untuk set manual jam
  //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

  //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  
  EEPROM.begin(512); //Initialasing EEPROM
  //delay(10);

  //Code serial & MP3 from : https://www.nyebarilmu.com/tutorial-mengakses-module-mp3-dfplayer-mini/?fbclid=IwAR0b0fNagVHdLAKPjjR_crMkXfdeIf9Y9McVnNZzBmFOVlnDO0IH_zVg2z4
  Serial.begin (115200);
  delay(100);

  tampilInfoRTC();
  delay(1000);

//-----------------------------------------------------------------------------------------------SETUP--------------------------------------------------------------------------------------//
  
  Serial.println("Configuring access point...");

    ssid = "AB LED Auto Murottal"; //"ABLed_NodeMCU_ESP8266";
    password = "bismillah";  //"goodluck";
    Serial.print("SSID: ");
    Serial.println(ssid);
    Serial.println("Reading pass");
    Serial.print("PASS: ");
    Serial.println(password);
    Serial.println("Setting soft-AP ... ");
    WiFi.softAP(ssid, password);  //--> Start Making ESP8266 NodeMCU as an access point
    Serial.print("Connect your wifi laptop/mobile phone to this NodeMCU Access Point : ");
    Serial.println(ssid);


  Serial.println("");

  IPAddress apip = WiFi.softAPIP(); //--> Get the IP server
  Serial.print("NodeMCU IP : ");
  Serial.println(apip); //--> Prints the NodeMCU IP address
  
  server.begin(); //--> Start server
  Serial.println("HTTP server started");
  //----------------------------------------
  udp.begin(localPort);
  Serial.print("Local Port : ");
  Serial.println(udp.localPort());
  Serial.println();
  Serial.println();
  //===========================================

  mp3Serial.begin (9600);
  delay(1000);
  Serial.println();
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!ABLedDFPlayer.begin(mp3Serial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true);
  }
  Serial.println(F("DFPlayer Mini online."));

  pinMode(PIN_BUSY, INPUT);
  pinMode(_RELAY, OUTPUT);

  //pinMode(MICSIG, INPUT);
  //pinMode(LEDMIC, OUTPUT);

  digitalWrite(_RELAY, 1); //Matikan relay
  //digitalWrite(LEDMIC, 0);  //Matikan LED Indikator MIC

  pinMode(LED_BUILTIN, OUTPUT); 
  for (int i=0; i>= 10; i++)
  {
    if (i%2 == 0)
    {
      digitalWrite(LED_BUILTIN, LOW); //--> Turn off Led On Board
      delay(1000);
    }
    else
    {
      digitalWrite(LED_BUILTIN, HIGH); //--> Turn off Led On Board
      delay(1000);
    }
  }
  

  tMain.every(6000, cekPlayMP3);
  //tMain.every(2000, alarmSholat);
  //tMain.every(1000, tampilJadwalSholat);

  loadDataEEPROM();
  
  ABLedDFPlayer.volume(volumeMP3);  //Set volume value. From 0 to 30

}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

//-----------------------------------------------------------------------------------------------LOOP---------------------------------------------------------------------------------------//
void loop() {
  // put your main code here, to run repeatedly:
  receive_packet();

  //Arduino kirim ke B4A Android
  if (Serial.available() > 0) {
    char inChar = Serial.read();
    inString += inChar;
    if (inChar == '\n') {
      inString.toCharArray(replyBuffer, 50);
      udp.beginPacket(DestinationIP, localPort);  //2000);
      udp.write(replyBuffer);
      udp.endPacket();
      inString="";
    }
  }

  if (ABLedDFPlayer.available()) {
    printDetail(ABLedDFPlayer.readType(), ABLedDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
  }

  if (flagCekPlayMP3 == 0)
  {
    tMain.update();
  }
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//writeOnAddress(4, 3);// set day of week manually (1=Sunday, 7=Saturday) ==> Wednesday 4 
//void writeOnAddress(byte value, int address)
void writeOnAddress(byte value, byte address){
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(address);
  Wire.write(decToBcd(value));
  Wire.endTransmission();
}

byte decToBcd(byte val)
{
  return ( (val / 10 * 16) + (val % 10) );
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

void playSuara(int idSuara, int delayStop, int delaySuara)
{
  ABLedDFPlayer.stop();
  delay(delayStop);
  ABLedDFPlayer.play(idSuara);
  delay(delaySuara);
}

void suaraAmpliOnOff(int onOff)
{
  switch (onOff)
  {
    case 0: //ampli off
      playSuara(nadaON, 200, 200);
      break;

    case 1: //ampli on
      playSuara(nadaOFF, 200, 200);
      break;
  }
}

void suaraInfoJam(int jamMenitDetik)
{
  int jam = jamMenitDetik / 10000;            //Misal jam 124403, hasilnya 12
  int menit = (jamMenitDetik % 10000) / 100;
  int detik = (jamMenitDetik % 10000) % 100;

  //Info Jam
  playSuara(33, 200, 1500);
  if (jam < 10)
  {
    suaraSatuan(jam);
  }
  else if (jam >= 10 && jam < 20)
  {
    suaraBelasan(jam);
  }
  else
  {
    suaraPuluhan(jam);
  }

  //Info Menit
  playSuara(51, 200, 1500);   //suara lewat
  if (menit < 10)
  {
    suaraSatuan(menit);
  }
  else if (menit >= 10 && menit < 20)
  {
    suaraBelasan(menit);
  }
  else
  {
    suaraPuluhan(menit);
  }
  playSuara(34, 200, 1000); //suara menit
}

void suaraInfoTanggal(int tglBlnThn)
{
  /*
  int jam = jamMenitDetik / 10000;            //Misal jam 124403, hasilnya 12
  int menit = (jamMenitDetik % 10000) / 100;
  int detik = (jamMenitDetik % 10000) % 100;

  //Info Jam
  playSuara(33, 200, 1500);
  if (jam < 10)
  {
    suaraSatuan(jam);
  }
  else if (jam >= 10 && jam < 20)
  {
    suaraBelasan(jam);
  }
  else
  {
    suaraPuluhan(jam);
  }

  //Info Menit
  playSuara(51, 200, 1500);   //suara lewat
  if (menit < 10)
  {
    suaraSatuan(menit);
  }
  else if (menit >= 10 && menit < 20)
  {
    suaraBelasan(menit);
  }
  else
  {
    suaraPuluhan(menit);
  }
  playSuara(34, 200, 1000); //suara menit
  */
}


void suaraSatuan(int nilai)
{
  switch (nilai)
  {
    case 0:
      playSuara(45, 200, 1000);
      break;
    case 1:
      playSuara(36, 200, 1000);
      break;
    case 2:
      playSuara(37, 200, 1000);
      break;
    case 3:
      playSuara(38, 200, 1000);
      break;
    case 4:
      playSuara(39, 200, 1000);
      break;
    case 5:
      playSuara(40, 200, 1000);
      break;
    case 6:
      playSuara(41, 200, 1000);
      break;
    case 7:
      playSuara(42, 200, 1000);
      break;
    case 8:
      playSuara(43, 200, 1400);
      break;
    case 9:
      playSuara(44, 200, 1400);
      break;
  }
}

void suaraBelasan(int nilai)
{
  if (nilai == 10)
  {
    playSuara(49, 200, 1400);   //suara sepuluh
  }
  else if (nilai == 11)
  {
    playSuara(50, 200, 1400);   //suara sebelas
  }
  else
  {
    suaraSatuan(nilai % 10);
    playSuara(48, 200, 1000);   //suara belas
  }
}

void suaraPuluhan(int nilai)
{
  suaraSatuan(nilai / 10);
  playSuara(47, 200, 1000);;   //suara puluh
  if (nilai % 10 != 0)
  {
    suaraSatuan(nilai % 10);
  }
}

void suaraRatusan(int nilai)
{
  if ((nilai / 100) == 1)
  {
    playSuara(58, 200, 1500);   //suara seratus
  }
  else if ((nilai / 100) > 1)
  {
    suaraSatuan(nilai / 100);
    playSuara(57, 200, 1000);  //suara ratus
  }

  if ((nilai % 100) > 0 && (nilai % 100) < 10)
  {
    suaraSatuan(nilai % 100);
  }
  else if ((nilai % 100) >= 10 && (nilai % 100) < 20)
  {
    suaraBelasan(nilai % 100);
  }
  else if ((nilai % 100) >= 20)
  {
    suaraPuluhan(nilai % 100);
  }
}

void suaraRibuan(int nilai)
{
  if ((nilai / 1000) == 1)
  {
    playSuara(59, 200, 1500);   //suara seribu
  }
  else if ((nilai / 1000) > 1)
  {
    suaraSatuan(nilai / 1000);
    playSuara(56, 200, 1000);   //suara ribu
  }

  if ((nilai % 1000) >= 1)
  {
    suaraRatusan(nilai % 1000);
  }
}

void tesSuaraAngka()
{
  //for (int i=31; i>59; i++)
  //{
    //if (i >= 36 && i <= 45)
    //{
      //suaraSatuan(i); 
      //delay(2000);
    //}
    //else
    //{
      //playSuara(i, 200, 2000);
    //}
  //}
  playSuara(31, 200, 2000);
  playSuara(32, 200, 2000);
  playSuara(33, 200, 2000);
  playSuara(34, 200, 2000);
  playSuara(35, 200, 2000);
  playSuara(36, 200, 2000);
  playSuara(37, 200, 2000);
  playSuara(38, 200, 2000);
  playSuara(39, 200, 2000);
  playSuara(40, 200, 2000);
  playSuara(41, 200, 2000);
  playSuara(42, 200, 2000);
  playSuara(43, 200, 2000);
  playSuara(44, 200, 2000);
  playSuara(45, 200, 2000);
  playSuara(46, 200, 2000);
  playSuara(47, 200, 2000);
  playSuara(48, 200, 2000);
  playSuara(49, 200, 2000);
  playSuara(50, 200, 2000);
  playSuara(51, 200, 2000);
  playSuara(52, 200, 2400);
  playSuara(53, 200, 2000);
  playSuara(54, 200, 2000);
  playSuara(55, 200, 2400);
  playSuara(56, 200, 2000);
  playSuara(57, 200, 2000);
  playSuara(58, 200, 2000);
  playSuara(59, 200, 2000);
}

void tampilJadwalSholat() {

  jadwalSholat();

  static uint8_t i;
  static uint32_t pM;
  uint32_t cM = millis();
  
  char sholat[7];
  char jam[5];
  char TimeName[][9] = {"Subuh","Terbit","Dzuhur","Ashar","Terbenam","Maghrib","Isya'"};
  int hours, minutes;

  if (cM - pM >= 10) {
    
    pM = cM;

    if (i == 1) {i = 2;} // Abaikan Terbit
    if (i == 4) {i = 5;} // Abaikan Terbenam

    get_float_time_parts(times[i], hours, minutes);
  
    minutes = minutes + ihti;

    if (minutes >= 60) {
      minutes = minutes - 60;
      hours++;
    }

    String sholat = TimeName[i];
    sprintf(jam,"%02d:%02d", hours, minutes);     

    Serial.print("Sholat ");
    Serial.print(sholat);
    Serial.print(" : ");
    Serial.println(jam);
    
    i++;

    if (i > 6) {    //Waktu tanbih imsyak
      get_float_time_parts(times[0], hours, minutes);
      minutes = minutes + ihti;
      if (minutes < 11) {
        minutes = 60 - minutes;
        hours --;
      } else {
        minutes = minutes - 10 ;
      }
      sprintf(jam,"%02d:%02d", hours, minutes);
      
      Serial.print("Waktu Tanbih Imsyak : ");
      Serial.println(jam);

      i = 0; 
    }  
  }
}

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//----------------------------------------------------------------------
//TAMPILKAN Jadwal Sholat

void jadwalSholat() {
  /*
    CALCULATION METHOD
    ------------------
    Jafari,   // Ithna Ashari
    Karachi,  // University of Islamic Sciences, Karachi
    ISNA,     // Islamic Society of North America (ISNA)
    MWL,      // Muslim World League (MWL)
    Makkah,   // Umm al-Qura, Makkah
    Egypt,    // Egyptian General Authority of Survey
    Custom,   // Custom Setting

    JURISTIC
    --------
    Shafii,    // Shafii (standard)
    Hanafi,    // Hanafi

    ADJUSTING METHOD
    ----------------
    None,        // No adjustment
    MidNight,   // middle of night
    OneSeventh, // 1/7th of night
    AngleBased, // angle/60th of night

    TIME IDS
    --------
    Fajr,
    Sunrise,
    Dhuhr,
    Asr,
    Sunset,
    Maghrib,
    Isha
  
  */

  //RtcDateTime now = Rtc.GetDateTime();
  DateTime now = rtc.now(); 
  
  int tahun = now.year();
  int bulan = now.month();
  int tanggal = now.day();
  float latitude = -0.00;   //-6.16;
  float longitude = 109.19; //106.61;
  int zonawaktu = 7;
  
  //set_calc_method(Karachi);
  set_calc_method(ISNA);
  set_asr_method(Shafii);
  set_high_lats_adjust_method(AngleBased);
  set_fajr_angle(20);
  set_isha_angle(18);  

  get_prayer_times(tahun, bulan, tanggal, latitude, longitude, zonawaktu, times);
}



//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void printDetail(uint8_t type, int value){
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number:"));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      Serial.print("Pin BUSY = ");
      Serial.println(digitalRead(PIN_BUSY));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError:"));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//Load data EEPROM
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void loadDataEEPROM()
{
  Serial.println("Load data EEPROM...");
  
  oPM = EEPROM.read(98);  //Cek opsi putar murottal. 
                          //0 = manual / bebas jam kapan saja, 1 = beberapa menit sebelum adzan

  jamMenitDetikMurottalSatu = String(EEPROM.read(99) * 10000 + EEPROM.read(100) * 100 + EEPROM.read(101));
  jamMenitDetikMurottalDua = String(EEPROM.read(102) * 10000 + EEPROM.read(103) * 100 + EEPROM.read(104));
  jamMenitDetikMurottalTiga = String(EEPROM.read(105) * 10000 + EEPROM.read(106) * 100 + EEPROM.read(107));
  jamMenitDetikMurottalEmpat = String(EEPROM.read(108) * 10000 + EEPROM.read(109) * 100 + EEPROM.read(110));
  jamMenitDetikMurottalDefault = "000000";
  durasiMurottalSatu = EEPROM.read(111);
  durasiMurottalDua = EEPROM.read(112);
  durasiMurottalTiga = EEPROM.read(113);
  durasiMurottalEmpat = EEPROM.read(114);
  durasiMurottalDefaultOpsiBebas = 0;   //durasi 0 menit
  
  selisihMntMurottalShubuh = EEPROM.read(115);   //berapa menit sebelum adzan shubuh
  selisihMntMurottalDhuhur = EEPROM.read(116); //berapa menit sebelum adzan dhuhur
  selisihMntMurottalAshar = EEPROM.read(117);  ////berapa menit sebelum adzan ashar
  selisihMntMurottalMaghrib = EEPROM.read(118);  ////berapa menit sebelum adzan maghrib
  selisihMntMurottalEmpatWktDefault = 60; //60 menit sebelum adzan
  durasiMurottalShubuh = EEPROM.read(119);
  durasiMurottalDhuhur = EEPROM.read(120);
  durasiMurottalAshar = EEPROM.read(121);
  durasiMurottalMaghrib = EEPROM.read(122);
  durasiMurottalDefaultOpsiTdkBebas = 0; //durasi putar MP3 adalah 45 menit

  fileMurottalShubuhDanSatu = EEPROM.read(123);
  fileMurottalDhuhurDanDua = EEPROM.read(124);
  fileMurottalAsharDanTiga = EEPROM.read(125);
  fileMurottalMaghribDanEmpat = EEPROM.read(126);
  fileMurottalDefault = 1;

  idFileMur = EEPROM.read(127);

  jamOnAmpliShubuh = EEPROM.read(128);
  jamOffAmpliShubuh = EEPROM.read(129);
  jamOnAmpliDhuhur = EEPROM.read(130);
  jamOffAmpliDhuhur = EEPROM.read(131);
  jamOnAmpliAshar = EEPROM.read(132);
  jamOffAmpliAshar = EEPROM.read(133);
  jamOnAmpliMaghrib = EEPROM.read(134);
  jamOffAmpliMaghrib = EEPROM.read(135);
  jamOnAmpliIsya = EEPROM.read(136);
  jamOffAmpliIsya = EEPROM.read(137);
  jamStopMurottalShubuh = EEPROM.read(138);
  jamStopMurottalDhuhur = EEPROM.read(139);
  jamStopMurottalAshar = EEPROM.read(140);
  jamStopMurottalMaghrib = EEPROM.read(141);

  volumeMP3 = EEPROM.read(142);
  
  Serial.println("Data EEPROM berhasil di load...");
  
  //Serial.print("862-> Durasi On Ampli Shubuh: ");
  //Serial.println(jamOnAmpliShubuh);
  
  Serial.println();
}

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
String hitungJamStop(int jamMulai, int mntMulai, int durasi, int jamStop, int mntStop)
{
  //Serial.println("Menghitung jam stop dan menit stop.");
  String jamStopStr;
  String mntStopStr;
  
        if (durasi >= 60)
        {
          jamStop = jamMulai + (durasi / 60);
          mntStop = mntMulai + (durasi % 60);

          if (mntStop >= 60)
          {
            jamStop += mntStop / 60;
            mntStop = mntStop % 60;
          }
        }
        else
        {
          if (durasi + mntMulai >= 60)
          {
            jamStop = jamMulai + ((durasi + mntMulai) / 60);
            mntStop = (durasi + mntMulai) % 60;
          }
          else
          {
            jamStop = jamMulai;
            mntStop = mntMulai + durasi;
          }
        }

        if (jamStop < 10)
        {
            jamStopStr = "0" + String(jamStop);
        }
        else
        {
            jamStopStr = String(jamStop);
        }

        if (mntStop < 10)
        {
            mntStopStr = "0" + String(mntStop);
        }
        else
        {
            mntStopStr = String(mntStop);
        }

        //Serial.print("Jam stop dan menit stop: ");
        //Serial.println(jamStopStr + mntStopStr);
        
        return jamStopStr + mntStopStr;
}

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
void cekPlayMP3()
{ 
  DateTime now = rtc.now(); 

  if (now.hour() == 22 and now.minute() == 0)
  {
     Serial.println("Jam sekarang memasuki pukul 22.00 WIB, saatnya NodeMCU memasuki mode DEEP SLEEP selama 1 jam atau 3.600 detik atau 3.600.000.000 uS atau 3600e6 atau 3600e6.");
     delay(60000);
     ESP.deepSleep(3600e6);   //Deep sleep selama 1 jam atau 3.600 detik
     //ESP.deepSleep(0.06e9); //60 detik, for testing
  }

  if (now.hour() == 23 and now.minute() == 5)
  {
     Serial.println("Jam sekarang memasuki pukul 23.05 WIB, saatnya NodeMCU memasuki mode DEEP SLEEP selama 1 jam atau 3.600 detik atau 3.600.000.000 uS atau 3600e6 atau 3600e6.");
     delay(60000);
     ESP.deepSleep(3600e6);   //Deep sleep selama 1 jam atau 3.600 detik
     //ESP.deepSleep(0.06e9); //60 detik, for testing
  }

  if (now.hour() == 0 and now.minute() == 10)
  {
     Serial.println("Jam sekarang memasuki pukul 00.10 WIB, saatnya NodeMCU memasuki mode DEEP SLEEP selama 1 jam atau 3.600 detik atau 3.600.000.000 uS atau 3600e6 atau 3600e6.");
     delay(60000);
     ESP.deepSleep(3600e6);   //Deep sleep selama 1 jam atau 3.600 detik
     //ESP.deepSleep(0.06e9); //60 detik, for testing
  }

  if (now.hour() == 1 and now.minute() == 15)
  {
     Serial.println("Jam sekarang memasuki pukul 01.15 WIB, saatnya NodeMCU memasuki mode DEEP SLEEP selama 1 jam atau 3.600 detik atau 3.600.000.000 uS atau 3600e6 atau 3600e6.");
     delay(60000);
     ESP.deepSleep(3600e6);   //Deep sleep selama 1 jam atau 3.600 detik
     //ESP.deepSleep(0.06e9); //60 detik, for testing
  }

  /*
  if (now.hour() == 7 and now.minute() == 0)
  {
     Serial.println("Jam sekarang memasuki pukul 07.00 WIB, saatnya NodeMCU memasuki mode DEEP SLEEP selama 1 jam atau 3.600 detik atau 3.600.000.000 uS atau 3600e6.");
     delay(60000);
     ESP.deepSleep(3600e6);  //Deep sleep selama 1 jam atau 3.600 detik
     //ESP.deepSleep(60000e3);  //60 detik juga, sama dengan 60e6
  }

  if (now.hour() == 8 and now.minute() == 5)
  {
     Serial.println("Jam sekarang memasuki pukul 08.05 WIB, saatnya NodeMCU memasuki mode DEEP SLEEP selama 1 jam atau 3.600 detik atau 3.600.000.000 uS atau 3600e6.");
     delay(60000);
     ESP.deepSleep(3600e6);  //Deep sleep selama 1 jam atau 3.600 detik
     //ESP.deepSleep(60000e3);  //60 detik juga, sama dengan 60e6
  }

  if (now.hour() == 9 and now.minute() == 10)
  {
     Serial.println("Jam sekarang memasuki pukul 09.10 WIB, saatnya NodeMCU memasuki mode DEEP SLEEP selama 1 jam atau 3.600 detik atau 3.600.000.000 uS atau 3600e6.");
     delay(60000);
     ESP.deepSleep(3600e6);  //Deep sleep selama 1 jam atau 3.600 detik
     //ESP.deepSleep(60000e3);  //60 detik juga, sama dengan 60e6
  }
  */
  
  if (oPM == 0) //Murottal waktu bebas
  {
    Serial.println("");
    Serial.println("Murottal Mode Waktu Bebas.");

  int durasiMS = durasiMurottalSatu;
  int durasiMD = durasiMurottalDua;
  int durasiMT = durasiMurottalTiga;
  int durasiME = durasiMurottalEmpat;

  Serial.println(String(now.hour()) + ":" + String(now.minute()) + ":" + String(now.second()));
  Serial.print("Durasi Murottal Satu: ");
  Serial.println(durasiMS);
  Serial.print("Durasi Murottal Dua: ");
  Serial.println(durasiMD);
  Serial.print("Durasi Murottal Tiga: ");
  Serial.println(durasiMT);
  Serial.print("Durasi Murottal Empat: ");
  Serial.println(durasiME);
  Serial.println("");

  Serial.print("File murottal shubuh & satu: ");
  Serial.println(fileMurottalShubuhDanSatu);
  Serial.print("File murottal dhuhur & dua: ");
  Serial.println(fileMurottalDhuhurDanDua);
  Serial.print("File murottal ashar & tiga: ");
  Serial.println(fileMurottalAsharDanTiga);
  Serial.print("File murottal maghrib & empat: ");
  Serial.println(fileMurottalMaghribDanEmpat);
  Serial.println("");
      
    int jam1 = jamMenitDetikMurottalSatu.toInt() / 10000;
    int mnt1 = (jamMenitDetikMurottalSatu.toInt() % 10000) / 100;
    int jam2 = jamMenitDetikMurottalDua.toInt() / 10000;
    int mnt2 = (jamMenitDetikMurottalDua.toInt() % 10000) / 100;
    int jam3 = jamMenitDetikMurottalTiga.toInt() / 10000;
    int mnt3 = (jamMenitDetikMurottalTiga.toInt() % 10000) / 100;
    int jam4 = jamMenitDetikMurottalEmpat.toInt() / 10000;
    int mnt4 = (jamMenitDetikMurottalEmpat.toInt() % 10000) / 100;

    int jamStop1 = ((hitungJamStop(jam1, mnt1, durasiMS, 0, 0)).toInt()) / 100;
    int mntStop1 = ((hitungJamStop(jam1, mnt1, durasiMS, 0, 0)).toInt()) % 100;
    int jamStop2 = ((hitungJamStop(jam2, mnt2, durasiMD, 0, 0)).toInt()) / 100;
    int mntStop2 = ((hitungJamStop(jam2, mnt2, durasiMD, 0, 0)).toInt()) % 100;
    int jamStop3 = ((hitungJamStop(jam3, mnt3, durasiMT, 0, 0)).toInt()) / 100;
    int mntStop3 = ((hitungJamStop(jam3, mnt3, durasiMT, 0, 0)).toInt()) % 100;
    int jamStop4 = ((hitungJamStop(jam4, mnt4, durasiME, 0, 0)).toInt()) / 100;
    int mntStop4 = ((hitungJamStop(jam4, mnt4, durasiME, 0, 0)).toInt()) % 100;
    
    
    Serial.print("Jam Putar 1: ");
    Serial.print(jam1);
    Serial.print(":");
    Serial.println(mnt1);
    Serial.print("Jam Stop 1: ");
    Serial.print(jamStop1);
    Serial.print(":");
    Serial.println(mntStop1);
    
    Serial.print("Jam Putar 2: ");
    Serial.print(jam2);
    Serial.print(":");
    Serial.println(mnt2);
    Serial.print("Jam Stop 2: ");
    Serial.print(jamStop2);
    Serial.print(":");
    Serial.println(mntStop2);
    
    Serial.print("Jam Putar 3: ");
    Serial.print(jam3);
    Serial.print(":");
    Serial.println(mnt3);
    Serial.print("Jam Stop 3: ");
    Serial.print(jamStop3);
    Serial.print(":");
    Serial.println(mntStop3);
    
    Serial.print("Jam Putar 4: ");
    Serial.print(jam4);
    Serial.print(":");
    Serial.println(mnt4);
    Serial.print("Jam Stop 4: ");
    Serial.print(jamStop4);
    Serial.print(":");
    Serial.println(mntStop4);
  }
  else  //Mode putar murottal beberapa menit sebelum adzan
  {
    //Serial.println("");
    //Serial.println("Murottal Mode 2, Satu Jam Sebelum adzan.");
    //RtcDateTime now = Rtc.GetDateTime();  
     //DateTime now = rtc.now(); 

    int Hari = now.dayOfTheWeek();
    int Hor = now.hour();
    int Min = now.minute();
    int Sec = now.second();

    int jamSkr = (Hor * 100) + Min;
    
    jadwalSholat();

    int hours, minutes, seconds;

    // Tanbih Imsak
    get_float_time_parts(times[0], hours, minutes);
    minutes = minutes + ihti;

    if (minutes < 10) { //jika wkt sholat shubuh, menitnya lbh kecil dari 10, maka set wkt tanbih imsak berkurang 10 utk menitnya dan berkurang 1 utk jamnya
    
      minutes = 60 - minutes; //Cek lagi hitungan tanbih ini. Coba liat / contoh wkt shubuh stlh ditambah wkt ihti gmn perhitungannya
      hours --;
    
    } else {
    
      minutes = minutes - 10 ;  // wkt sholat shubuh menitnya 10 atau lbh besar, maka menitnya lgsg dikurangkan 10 saja
    
    }

    if ((hours - Hor == 1) && (Min - minutes == 0)) 
    {   //Jika jam saat ini dan menit saat ini sama dengan jam dan menit waktu tanbih, maka eksekusi kode berikut (bunyikan buzzer)

    }

    // Subuh
    get_float_time_parts(times[0], hours, minutes);
    minutes = minutes + ihti;
    
    if (minutes >= 60) {
    
      minutes = minutes - 60;
      hours ++;
    }

    //Serial.print("1122-> Jam Sholat Shubuh: ");
    //Serial.println((hours*100) + minutes);
    
    //int jamMntPlayMrtSbh = ((hours - 1) * 100) + minutes;
    //int jamMntPlayAmpSbh = ((hours - 1) * 100) + minutes;
    //int jamMntStopMrtSbh = cekJamMntOffMurottal((hours * 100) + minutes);
    //int jamMntStopAmpSbh = cekJamMntOffAmpli((hours * 100) + minutes);

    int jamMntPlayAmpSbh = cekJamMntOnAmpli((hours * 100) + minutes, 1);
    int jamMntPlayMrtSbh = jamMntPlayAmpSbh;
    int jamMntStopMrtSbh = cekJamMntOffMurottal((hours * 100) + minutes, 1);
    int jamMntStopAmpSbh = cekJamMntOffAmpli((hours * 100) + minutes, 1);
    
    // Dzuhur
    get_float_time_parts(times[2], hours, minutes);
    //minutes = minutes + ihti;
    minutes = minutes + ihti;

    if (minutes >= 60) {
    
      minutes = minutes - 60;
      hours ++;
    }
    
    int jamMntPlayAmpDhr = cekJamMntOnAmpli((hours * 100) + minutes, 2);
    int jamMntPlayMrtDhr = jamMntPlayAmpDhr;
    int jamMntStopMrtDhr = cekJamMntOffMurottal((hours * 100) + minutes, 2);
    int jamMntStopAmpDhr = cekJamMntOffAmpli((hours * 100) + minutes, 2);
    //Serial.print("Hari = ");
    //Serial.println(Hari);
    
    if (Hari == 5)  // kalau hari jumat
    {
      Serial.println("1157-> Hari = Jum'at / 5.");
      int jamStopMrtDhr = jamMntStopMrtDhr / 100;
      int mntStopMrtDhr = (jamMntStopMrtDhr % 100) - 20;
      
      if (mntStopMrtDhr < 0)
      {
        mntStopMrtDhr = 60 + mntStopMrtDhr;
        jamStopMrtDhr--;
      }
      jamMntStopMrtDhr = (jamStopMrtDhr * 100) + mntStopMrtDhr;

      
      int jamStopAmpDhr = jamMntStopAmpDhr / 100;
      int mntStopAmpDhr = (jamMntStopAmpDhr % 100) + 25;
      
      if (mntStopAmpDhr >= 60)
      {
        mntStopAmpDhr = mntStopAmpDhr - 60;
        jamStopAmpDhr++;
      }
      jamMntStopAmpDhr = (jamStopAmpDhr * 100) + mntStopAmpDhr;
    }
    
    // Ashar
    get_float_time_parts(times[3], hours, minutes);
    minutes = minutes + ihti;

    if (minutes >= 60) {
    
      minutes = minutes - 60;
      hours ++;  
    }
    
    int jamMntPlayAmpAsr = cekJamMntOnAmpli((hours * 100) + minutes, 3);
    int jamMntPlayMrtAsr = jamMntPlayAmpAsr;
    int jamMntStopMrtAsr = cekJamMntOffMurottal((hours * 100) + minutes, 3);
    int jamMntStopAmpAsr = cekJamMntOffAmpli((hours * 100) + minutes, 3);

    // Maghrib
    get_float_time_parts(times[5], hours, minutes);
    minutes = minutes + ihti;

    if (minutes >= 60) {
    
      minutes = minutes - 60;
      hours ++;
    }
    int jamMntPlayAmpMgr = cekJamMntOnAmpli((hours * 100) + minutes, 4);
    int jamMntPlayMrtMgr = jamMntPlayAmpMgr;
    int jamMntStopMrtMgr = cekJamMntOffMurottal((hours * 100) + minutes, 4);
    int jamMntStopAmpMgr = cekJamMntOffAmpli((hours * 100) + minutes, 4);

  // Isya'
    get_float_time_parts(times[6], hours, minutes);
    minutes = minutes + ihti;

    if (minutes >= 60) {
    
      minutes = minutes - 60;
      hours ++;
    }

    int jamMntPlayAmpIsy = cekJamMntOnAmpli((hours * 100) + minutes, 5);
    int jamMntStopAmpIsy = cekJamMntOffAmpli((hours * 100) + minutes, 5);

    //Serial.print("1224-> Jadwal Sholat Isya : ");
    //Serial.println((hours * 100) + minutes);
      
    
    
    if (jamSkr >= jamMntPlayAmpSbh and jamSkr < jamMntStopAmpSbh)  //Kalau waktu sekarang masuk rentang waktu 1 jam sebelum dan 1 jam setelah adzan shubuh
    {
      if (digitalRead(_RELAY) == 1)  //kalau ampli masih off
      {
        nyalakanAmpli();
        //playSuara(idFileMur, 200, 200);
      }
    }
    else if (jamSkr >= jamMntPlayAmpDhr and jamSkr < jamMntStopAmpDhr)  //Kalau waktu sekarang masuk rentang waktu 1 jam sebelum dan 35 menit atau 1 jam setelah adzan Dzuhur
    {
      if (digitalRead(_RELAY) == 1)  //kalau ampli masih off
      {
        nyalakanAmpli();
      }
    }
    else if (jamSkr >= jamMntPlayAmpAsr and jamSkr < jamMntStopAmpAsr)  //Kalau waktu sekarang masuk rentang waktu 1 jam sebelum dan 1 jam setelah adzan Ashar
    {
      if (digitalRead(_RELAY) == 1)  //kalau ampli masih off
      {
        nyalakanAmpli();
      }
    }
    else if (jamSkr >= jamMntPlayAmpMgr and jamSkr < jamMntStopAmpMgr)  //Kalau waktu sekarang masuk rentang waktu 1 jam sebelum dan 1 jam setelah adzan Maghrib
    {
      if (digitalRead(_RELAY) == 1)  //kalau ampli masih off
      {
        nyalakanAmpli();
      }
    }
    else if (jamSkr >= jamMntPlayAmpIsy and jamSkr < jamMntStopAmpIsy)  //Kalau waktu sekarang masuk rentang waktu 1 jam sebelum dan 1 jam setelah adzan Isya
    {
      if (digitalRead(_RELAY) == 1)  //kalau ampli masih off
      {
        nyalakanAmpli();
      }
    }
    else
    {
      if (digitalRead(PIN_BUSY) == 0) //kalau MP3 player masih play
      {
        ABLedDFPlayer.stop(); //maka stop MP3 player
        delay(200);
      }
      
      if (digitalRead(_RELAY) == 0)  //kalau ampli masih on
      {
        matikanAmpli();
      }
    }

      //CEK Murottal time
      if (jamSkr >= jamMntPlayMrtSbh and jamSkr < jamMntStopMrtSbh)
      {
        if (digitalRead(PIN_BUSY) == 1) //Kalau murottal off
        {
          playSuara(idFileMur, 200, 200);
        }
      }
      else if (jamSkr >= jamMntPlayMrtDhr and jamSkr < jamMntStopMrtDhr)
      {
        if (digitalRead(PIN_BUSY) == 1) //Kalau murottal off
        {
          playSuara(idFileMur, 200, 200);
        }
      }
      else if (jamSkr >= jamMntPlayMrtAsr and jamSkr < jamMntStopMrtAsr)
      {
        if (digitalRead(PIN_BUSY) == 1) //Kalau murottal off
        {
          playSuara(idFileMur, 200, 200);
        }
      }
      else if (jamSkr >= jamMntPlayMrtMgr and jamSkr < jamMntStopMrtMgr)
      {
        if (digitalRead(PIN_BUSY) == 1) //Kalau murottal off
        {
            playSuara(idFileMur, 200, 200);
        }
      }
      else
      {
        if (jamSkr >= jamMntStopMrtSbh)
        {
          if (digitalRead(PIN_BUSY) == 0)
          {
            ABLedDFPlayer.stop();
            delay(200);
            Serial.println("10 menit menuju adzan shubuh, murottal di-stop.");
          
            idFileMur++;
            writeEEPROM(127, idFileMur);
            EEPROM.commit();
            //loadDataEEPROM();
            Serial.print("File murottal selanjutnya (dzuhur) adalah Juzz: ");
            Serial.println(idFileMur);
          }
        }
      }

      if (flagTes2 == 1)
      {
        Serial.print("Jam Nyala Ampli: ");
        Serial.println(jamMntPlayAmpSbh);
        Serial.print("Jam Putar murottal shubuh: ");
        Serial.println(jamMntPlayMrtSbh);
        Serial.print("Jam Stop Murottal: ");
        Serial.println(jamMntStopMrtSbh);
        Serial.print("Jam stop Ampli: ");
        Serial.println(jamMntStopAmpSbh);
        Serial.println("");
        
        Serial.print("Jam Nyala Ampli: ");
        Serial.println(jamMntPlayAmpDhr);
        Serial.print("Jam Putar murottal Dzuhur: ");
        Serial.println(jamMntPlayMrtDhr);
        Serial.print("Jam Stop Murottal: ");
        Serial.println(jamMntStopMrtDhr);
        Serial.print("Jam stop Ampli: ");
        Serial.println(jamMntStopAmpDhr);
        Serial.println("");
        
        Serial.print("Jam Nyala Ampli: ");
        Serial.println(jamMntPlayAmpAsr);
        Serial.print("Jam Putar murottal Ashar: ");
        Serial.println(jamMntPlayMrtAsr);
        Serial.print("Jam Stop Murottal: ");
        Serial.println(jamMntStopMrtAsr);
        Serial.print("Jam stop Ampli: ");
        Serial.println(jamMntStopAmpAsr);
        Serial.println("");
        
        Serial.print("Jam Nyala Ampli: ");
        Serial.println(jamMntPlayAmpMgr);
        Serial.print("Jam Putar murottal Maghrib: ");
        Serial.println(jamMntPlayMrtMgr);
        Serial.print("Jam Stop Murottal: ");
        Serial.println(jamMntStopMrtMgr);
        Serial.print("Jam stop Ampli: ");
        Serial.println(jamMntStopAmpMgr);
        Serial.println("");
        
        Serial.print("Jam Nyala Ampli Isya': ");
        Serial.println(jamMntPlayAmpIsy);
        Serial.print("Jam stop Ampli: ");
        Serial.println(jamMntStopAmpIsy);
        Serial.println("");
    
        flagTes2 = 0;
      }
  }
}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
void matikanAmpli()
{
  ABLedDFPlayer.stop();
  delay(200);
  ABLedDFPlayer.play(nadaOFF);
  delay(1400);
  digitalWrite(_RELAY, 1); //Matikan ampli
  delay(1000);
}

void nyalakanAmpli()
{
  digitalWrite(_RELAY, 0); //Nyalakan ampli
  delay(1000);
  ABLedDFPlayer.stop();
  delay(200);
  ABLedDFPlayer.play(nadaON);
  delay(200);
}
        
int cekJamMntOnAmpli(int jamMntSholat, int idSholat)
{
  int jamMntOnAmpli;

  int jamSholat = jamMntSholat / 100;
  int mntSholat = jamMntSholat % 100;
      
  int jamOn;
  int mntOn;
      
  switch (idSholat)
  {
    case 1:
      //Serial.print("1418-> cekJamMntOnAmpli Shubuh: ");
      //Serial.println(jamMntSholat);
      
      if (jamOnAmpliShubuh < 60)
      {
        mntOn = mntSholat - jamOnAmpliShubuh; //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
        jamOn = jamSholat;
      }
      else
      {
        jamOn = jamSholat - (jamOnAmpliShubuh / 60);
        mntOn = mntSholat - (jamOnAmpliShubuh % 60); //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
      }
      
      
      if (mntOn < 0)
      {
        jamOn = jamOn - 1;
        mntOn = mntOn + 60;
      }
      
      jamMntOnAmpli = (jamOn * 100) + mntOn;
      break;
  
    case 2:
      if (jamOnAmpliDhuhur < 60)
      {
        mntOn = mntSholat - jamOnAmpliDhuhur; //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
        jamOn = jamSholat;
      }
      else
      {
        jamOn = jamSholat - (jamOnAmpliDhuhur / 60);
        mntOn = mntSholat - (jamOnAmpliDhuhur % 60); //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
      }
      
      
      if (mntOn < 0)
      {
        jamOn = jamOn - 1;
        mntOn = mntOn + 60;
      }
      
      jamMntOnAmpli = (jamOn * 100) + mntOn;
      break;
      
    case 3:
      if (jamOnAmpliAshar < 60)
      {
        mntOn = mntSholat - jamOnAmpliAshar; //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
        jamOn = jamSholat;
      }
      else
      {
        jamOn = jamSholat - (jamOnAmpliAshar / 60);
        mntOn = mntSholat - (jamOnAmpliAshar % 60); //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
      }
      
      
      if (mntOn < 0)
      {
        jamOn = jamOn - 1;
        mntOn = mntOn + 60;
      }
      
      jamMntOnAmpli = (jamOn * 100) + mntOn;
      break;
      
    case 4:
      if (jamOnAmpliMaghrib < 60)
      {
        mntOn = mntSholat - jamOnAmpliMaghrib; //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
        jamOn = jamSholat;
      }
      else
      {
        jamOn = jamSholat - (jamOnAmpliMaghrib / 60);
        mntOn = mntSholat - (jamOnAmpliMaghrib % 60); //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
      }
      
      
      if (mntOn < 0)
      {
        jamOn = jamOn - 1;
        mntOn = mntOn + 60;
      }
      
      jamMntOnAmpli = (jamOn * 100) + mntOn;
      break;

    case 5:
      if (jamOnAmpliIsya < 60)
      {
        //Serial.print("jamOnAmpliIsya (durasi) : ");
        //Serial.println(jamOnAmpliIsya);
        //Serial.print("mntSholat: ");
        //Serial.println(mntSholat);
        
        mntOn = mntSholat - jamOnAmpliIsya; //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
        jamOn = jamSholat;

        //Serial.print("1513-> mntOn : ");
        //Serial.println(mntOn);
      }
      else
      {
        jamOn = jamSholat - (jamOnAmpliIsya / 60);
        mntOn = mntSholat - (jamOnAmpliIsya % 60); //jamOnAmpliDhuhur = durasi menit on ampli 5-30 menit sebelum adzan
      }
      
      
      if (mntOn < 0)
      {
        //Serial.print("1528-> jamOn1 : ");
        //Serial.println(jamOn);
        //Serial.print("mntOn2 : ");
        //Serial.println(mntOn);

        jamOn = jamOn - 1;
        mntOn = mntOn + 60;
      }

      
      jamMntOnAmpli = (jamOn * 100) + mntOn;
      
      //Serial.print("1538-> jamMntOnAMpli : ");
      //Serial.println(jamMntOnAmpli);
      
      break;
  }

  return jamMntOnAmpli;
}

int cekJamMntOffMurottal(int jamMntSholat)
{
  int jamSholat = jamMntSholat / 100;
  int mntSholat = jamMntSholat % 100;

  int mntStop = mntSholat + 50;
  int jamStop = jamSholat - 1;

  if (mntStop >= 60)
  {
    mntStop = mntStop - 60;
    jamStop = jamStop + 1;
  }

  int jamMntStopMurottal = (jamStop * 100) + mntStop;
  
  return jamMntStopMurottal;
}

int cekJamMntOffMurottal(int jamMntSholat, int idSholat)
{
  int jamMntStopMurottal;
  
  int jamSholat = jamMntSholat / 100;;
  int mntSholat = jamMntSholat % 100;;
      
  int mntStop;
  int jamStop;
  
  switch (idSholat)
  {
    case 1:
      mntStop = mntSholat - jamStopMurottalShubuh; //5-30 menit sebelum adzan
      jamStop = jamSholat ;

      if (mntStop < 0)
      {
        jamStop = jamStop - 1;
        mntStop = mntStop + 60;
      }
      
      jamMntStopMurottal = (jamStop * 100) + mntStop;
      break;
      
    case 2:
      mntStop = mntSholat - jamStopMurottalDhuhur; //5-30 menit sebelum adzan
      jamStop = jamSholat ;

      if (mntStop < 0)
      {
        jamStop = jamStop - 1;
        mntStop = mntStop + 60;
      }
      
      jamMntStopMurottal = (jamStop * 100) + mntStop;
      break;
      
    case 3:
      mntStop = mntSholat - jamStopMurottalAshar; //5-30 menit sebelum adzan
      jamStop = jamSholat ;

      if (mntStop < 0)
      {
        jamStop = jamStop - 1;
        mntStop = mntStop + 60;
      }
      
      jamMntStopMurottal = (jamStop * 100) + mntStop;
      break;
      
    case 4:
      mntStop = mntSholat - jamStopMurottalMaghrib; //5-30 menit sebelum adzan
      jamStop = jamSholat ;

      if (mntStop < 0)
      {
        jamStop = jamStop - 1;
        mntStop = mntStop + 60;
      }
      
      jamMntStopMurottal = (jamStop * 100) + mntStop;
      break;
  }

   return jamMntStopMurottal;
}


int cekJamMntOffAmpli(int jamMntSholat)
{
  int jamSholat = jamMntSholat / 100;
  int mntSholat = jamMntSholat % 100;

  //int mntStop = mntSholat + 60; // 1 jam setelah adzan
  int mntStop = mntSholat + 35;   //35 menit setelah adzan
  int jamStop = jamSholat;

  if (mntStop >= 60)
  {
    mntStop = mntStop - 60;
    jamStop = jamStop + 1;
  }

  int jamMntStopAmpli = (jamStop * 100) + mntStop;
  
  return jamMntStopAmpli;
}

int cekJamMntOffAmpli(int jamMntSholat, int idSholat)
{
  int jamSholat = jamMntSholat / 100;
  int mntSholat = jamMntSholat % 100;
  
  int jamMntStopAmpli;

  int mntStop;
  int jamStop;
  
  switch (idSholat)
  {    
    case 1:
      //int mntStop = mntSholat + 60; // 1 jam setelah adzan
      mntStop = mntSholat + jamOffAmpliShubuh;  //jamOffAmpliSubuh = durasi off ampli dimulai dari waktu adzan tiba
      jamStop = jamSholat;

      if (mntStop >= 60)
      {
        jamStop = jamStop + (mntStop / 60);
        mntStop = mntStop % 60;
      }

      jamMntStopAmpli = (jamStop * 100) + mntStop;
      break;
      
    case 2:
      mntStop = mntSholat + jamOffAmpliDhuhur;
      jamStop = jamSholat;

      if (mntStop >= 60)
      {
        jamStop = jamStop + (mntStop / 60);
        mntStop = mntStop % 60;
      }

      jamMntStopAmpli = (jamStop * 100) + mntStop;
      break;

    case 3:
      mntStop = mntSholat + jamOffAmpliAshar;
      jamStop = jamSholat;

      if (mntStop >= 60)
      {
        jamStop = jamStop + (mntStop / 60);
        mntStop = mntStop % 60;
      }

      jamMntStopAmpli = (jamStop * 100) + mntStop;
      break;
  
    case 4:
      mntStop = mntSholat + jamOffAmpliMaghrib;
      jamStop = jamSholat;

      if (mntStop >= 60)
      {
        jamStop = jamStop + (mntStop / 60);
        mntStop = mntStop % 60;
      }

      jamMntStopAmpli = (jamStop * 100) + mntStop;
      break;
  
      case 5:
      mntStop = mntSholat + (jamOffAmpliIsya);
      jamStop = jamSholat;

      if (mntStop >= 60)
      {
        jamStop = jamStop + (mntStop / 60);
        mntStop = mntStop % 60;
      }

      jamMntStopAmpli = (jamStop * 100) + mntStop;
      break;
  }
    
  return jamMntStopAmpli;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//


void tampilInfoRTC()
{
  DateTime now = rtc.now();       //Menampilkan RTC pada variable now

  Serial.print("Hari: ");
  Serial.println(now.dayOfTheWeek());
  Serial.print("Tanggal : ");
  Serial.print(now.day());        //Menampilkan Tanggal
  Serial.print("/");
  Serial.print(now.month());      //Menampilkan Bulan
  Serial.print("/");
  Serial.print(now.year());       //Menampilkan Tahun
  Serial.print(" ");
  
  Serial.print("Jam : ");
  Serial.print(now.hour());       //Menampilkan Jam
  Serial.print(":");
  Serial.print(now.minute());     //Menampilkan Menit
  Serial.print(":");
  Serial.print(now.second());     //Menampilkan Detik
  Serial.println();
 
  //delay(1000);
}

//----------------------------------------Procedure for receiving text / messages from the sender-------------------------------------------------------------------------------------------//
void receive_packet() {
  int packetSize = udp.parsePacket();
  if (packetSize) {
    IPAddress remoteIp = udp.remoteIP();
    //DestinationIP = udp.remoteIP();
    int len = udp.read(packetBuffer, 255);
    if (len > 0) packetBuffer[len] = 0;
    strCon = packetBuffer;
    Serial.println(packetBuffer);

    //-------------------------------Conditions for controlling LEDs
    if (strCon=="led on") {
      digitalWrite(LED_BUILTIN, LOW);
    }
    else if (strCon=="led off") {
      digitalWrite(LED_BUILTIN, HIGH);
    }
    else if (strCon=="nama ssid") {
      while(true)
      {
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
          //Serial.println(packetBuffer);

          if (strCon=="default")
          {
            writeEEPROM(97, 0);
            EEPROM.commit();
            Serial.println("EEPROM 97 jadi 0");
          }
          else
          {
            writeEEPROM(97, 4);
            writeEEPROM(0, strCon);
            
            //EEPROM.commit();
            Serial.println("EEPROM 97 jadi 4");
          }
          
          break;
        }
      }
    }
    else if (strCon=="password wifi") {
      while(true)
      {
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
          //Serial.println(packetBuffer);

          writeEEPROM(32, strCon);

          break;
        }
      }
    }
    else if (strCon=="set time") {
      Serial.println("Setting jam kontroler.");
      playSuara(53, 200, 3000);
      
      DateTime now = rtc.now(); 
      long val;
      int jam;
      int mnt;
      int dtk;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;

          val = strCon.toInt();
          Serial.println(val);
          
          if (val > -1)
          {
            jam = val / 10000;
            mnt = (val % 10000) / 100;
            dtk = (val % 10000) % 100;

            //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
            rtc.adjust(DateTime(now.year(), now.month(), now.day(), jam, mnt, dtk));
            playSuara(52, 200, 4000);
            suaraInfoJam((jam*10000) + (mnt*100) + dtk);
          }
          
          break;
        }
      }
    }
    else if (strCon=="set date") {
      Serial.println("Setting tanggal kontroler.");
      playSuara(54, 200, 3000);
      
      DateTime now = rtc.now(); 
      long val;
      int thn;
      int bln;
      int tgl;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;

          val = strCon.toInt();
          Serial.println(val);
          
          if (val > -1)
          {
            //thn = val / 10000;  //Format Tanggal 20210327
            //bln = (val % 10000) / 100;
            //tgl = (val % 10000) % 100;

            tgl = val / 1000000;    //Format Tanggal 27032021
            bln = (val % 1000000) / 10000;
            thn = (val % 1000000) % 10000;

            //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
            rtc.adjust(DateTime(thn, bln, tgl, now.hour(), now.minute(), now.second()));

            playSuara(55, 200, 4000);
            //suaraInfoJam((jam*10000) + (mnt*100) + dtk);
          }
          
          break;
        }
      }
    }
    else if (strCon=="set day") {
      Serial.println("Setting hari kontroler.");
      //playSuara(53, 200, 3000);
      
      //DateTime now = rtc.now(); 
      int val;
      //int jam;
      //int mnt;
      //int dtk;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;

          val = strCon.toInt();
          //val = atoi(strCon);
          Serial.println(val);
          
          if (val > -1)
          {
            //jam = val / 10000;
            //mnt = (val % 10000) / 100;
            //dtk = (val % 10000) % 100;

            //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
            writeOnAddress((int)val, 0x03);
            //writeOnAddress(val, 0x03);
            //playSuara(52, 200, 4000);
            //suaraInfoJam((jam*10000) + (mnt*100) + dtk);
          }
          
          break;
        }
      }
    }
    else if (strCon=="give me your ip") {
      Serial.println("IP request.");

      IPAddress remoteIp = udp.remoteIP();
      
      Serial.print("IP client: ");
      Serial.println(remoteIp);
      
      //char replyBuffer[50];

      Serial.println("Kirim Alamat IP.");
      Serial.println("ip" + WiFi.softAPIP().toString());
      ("ip" + WiFi.softAPIP().toString()).toCharArray(replyBuffer, 50);
      //udp.beginPacket(udp.remoteIP, udp.remotePort);
      udp.beginPacket(remoteIp, 2000);
      udp.write(replyBuffer);
      udp.endPacket();

      inString = "pt2000";
      Serial.println("Kirim Nomor Port.");
      inString.toCharArray(replyBuffer, 50);
      udp.beginPacket(remoteIp, 2000);
      udp.write(replyBuffer);
      udp.endPacket();

      Serial.println("Pengiriman selesai.");
    }
    else if (strCon=="tampil waktu") {
      while(true)
      {
        static uint32_t pM;
        uint32_t cM = millis();

        if (cM - pM >= 1000)
        {
          pM = cM;
          tampilInfoRTC(); 
        }
  
        if (udp.parsePacket()) 
        {
            remoteIp = udp.remoteIP();
            len = udp.read(packetBuffer, 255);
            if (len > 0) packetBuffer[len] = 0;
            strCon = packetBuffer;

            if (strCon == "kembali")
            {
              break;
            }
         }
         delay(100);
       } 
    }
    else if (strCon=="info waktu") {
      Serial.println("Suara informasi waktu");
      
      DateTime now = rtc.now();

      int jamMenitDetik = (now.hour() * 10000) + (now.minute() * 100) + now.second();
      suaraInfoJam(jamMenitDetik);
    }
    else if (strCon=="tampilJadwalSholat") {
      Serial.println("Menampilkan jadwal sholat: ");
      //for (int i=0; i>5; i++)
      //{
        tampilJadwalSholat();
        //delay(500);
      //}
    }
    else if (strCon=="opsi putar murottal") {
      Serial.println("Opsi putar murottal, 0 waktu bebas, 1 beberapa menit sebelum adzan.");
      Serial.print("Nilai EEPROM 98 saat ini: ");
      Serial.println(EEPROM.read(98));
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
          
          if (strCon == "0")    //Waktu bebas
          {
            writeEEPROM(98, 0);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else if (strCon == "1")   //beberapa menit sebelum adzan
          {
            writeEEPROM(98, 1);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else if (strCon != "0" or strCon != "1")
          {
            Serial.println("Masukkan angka 0 atau 1");
          }
        }
      }
    }
    else if (strCon=="opsi 1 jam putar murottal satu") {
      Serial.println("Opsi 1 (bebas) jam putar murottal satu.");
      Serial.println("Masukkan Jam dan Menit murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 99-101.");

      long val;
      int jam;
      int mnt;
      int dtk;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          val = strCon.toInt();
          Serial.println(val);
          
          if (val > -1)
          {
            jam = val / 10000;
            mnt = (val % 10000) / 100;
            dtk = (val % 10000) % 100;

            writeEEPROM(99, jam);
            writeEEPROM(100, mnt);
            writeEEPROM(101, dtk);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();

            Serial.print("Jam putar murottal satu sudah diset. Waktu putar: ");
            Serial.print(EEPROM.read(99));
            Serial.print(EEPROM.read(100));
            Serial.println(EEPROM.read(101));
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: untuk tanggal 20210129, untuk jam 214859");
          }
        }
      }
    }
    else if (strCon=="opsi 1 jam putar murottal dua") {
      Serial.println("Opsi 1 (bebas) jam putar murottal dua.");
      Serial.println("Masukkan Jam dan Menit murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 102-104.");

      long val;
      int jam;
      int mnt;
      int dtk;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          val = strCon.toInt();
          Serial.println(val);
          
          if (val > -1)
          {
            Serial.println(val);
            
            jam = val / 10000;
            mnt = (val % 10000) / 100;
            dtk = (val % 10000) % 100;

            Serial.println("Write to EEWPROM");
            
            writeEEPROM(102, jam);
            writeEEPROM(103, mnt);
            writeEEPROM(104, dtk);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: untuk tanggal 20210129, untuk jam 214859");
          }
        }
      }
    }
    else if (strCon=="opsi 1 jam putar murottal tiga") {
      Serial.println("Opsi 1 (bebas) jam putar murottal tiga.");
      Serial.println("Masukkan Jam dan Menit murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 105-107.");

      long val;
      int jam;
      int mnt;
      int dtk;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          val = strCon.toInt();
          Serial.println(val);
          
          if (val > -1)
          {
            jam = val / 10000;
            mnt = (val % 10000) / 100;
            dtk = (val % 10000) % 100;

            writeEEPROM(105, jam);
            writeEEPROM(106, mnt);
            writeEEPROM(107, dtk);
            EEPROM.commit();
            
            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: untuk tanggal 20210129, untuk jam 214859");
          }
        }
      }
    }
    else if (strCon=="opsi 1 jam putar murottal empat") {
      Serial.println("Opsi 1 (bebas) jam putar murottal empat.");
      Serial.println("Masukkan Jam dan Menit murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 108-110.");

      long val;
      int jam;
      int mnt;
      int dtk;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          val = strCon.toInt();
          Serial.println(val);
          
          if (val > -1)
          {
            jam = val / 10000;
            mnt = (val % 10000) / 100;
            dtk = (val % 10000) % 100;

            writeEEPROM(108, jam);
            writeEEPROM(109, mnt);
            writeEEPROM(110, dtk);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();

            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: untuk tanggal 20210129, untuk jam 214859");
          }
        }
      }
    }
    else if (strCon=="opsi 1 durasi putar murottal satu") {
      Serial.println("Opsi 1 durasi putar murottal satu.");
      Serial.println("Masukkan Menit berapa lama murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 111.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(111, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 1 durasi putar murottal dua") {
      Serial.println("Opsi 1 durasi putar murottal dua.");
      Serial.println("Masukkan Menit berapa lama murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 112.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(112, durasi);
            EEPROM.commit();
            
            Serial.println("EEPROM Committed");
            loadDataEEPROM();

            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 1 durasi putar murottal tiga") {
      Serial.println("Opsi 1 durasi putar murottal tiga.");
      Serial.println("Masukkan Menit berapa lama murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 113.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(113, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 1 durasi putar murottal empat") {
      Serial.println("Opsi 1 durasi putar murottal empat.");
      Serial.println("Masukkan Menit berapa lama murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 114.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(114, durasi);
            EEPROM.commit();
            
            Serial.println("EEPROM Committed");
            loadDataEEPROM();

            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 2 jam putar murottal shubuh") {
      Serial.println("opsi 2 jam putar murottal shubuh");
      Serial.println("Masukkan Menit berapa lama sebelum adzan murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 115.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(115, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 2 jam putar murottal dhuhur") {
      Serial.println("opsi 2 jam putar murottal dhuhur");
      Serial.println("Masukkan Menit berapa lama sebelum adzan murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 116.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(116, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 2 jam putar murottal ashar") {
      Serial.println("opsi 2 jam putar murottal ashar");
      Serial.println("Masukkan Menit berapa lama sebelum adzan murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 117.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(117, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 2 jam putar murottal maghrib") {
      Serial.println("opsi 2 jam putar murottal ashar");
      Serial.println("Masukkan Menit berapa lama sebelum adzan murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 118.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(118, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 2 durasi putar murottal shubuh") {
      Serial.println("opsi 2 durasi putar murottal shubuh.");
      Serial.println("Masukkan Menit lama durasi murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 119.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(119, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 2 durasi putar murottal dhuhur") {
      Serial.println("opsi 2 durasi putar murottal dhuhur.");
      Serial.println("Masukkan Menit lama durasi murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 120.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(120, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 2 durasi putar murottal ashar") {
      Serial.println("opsi 2 durasi putar murottal ashar.");
      Serial.println("Masukkan Menit lama durasi murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 121.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(121, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="opsi 2 durasi putar murottal maghrib") {
      Serial.println("opsi 2 durasi putar murottal maghrib.");
      Serial.println("Masukkan Menit lama durasi murottal akan diputar.");
      Serial.println("Alamat EEPROM digunakan 122.");

      int durasi;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          durasi = strCon.toInt();
          Serial.println(durasi);
          
          if (durasi > 0 && durasi < 256)
          {
            writeEEPROM(122, durasi);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, cth: 60 untuk durasi 60 menit, maximum durasi 255 menit");
          }
        }
      }
    }
    else if (strCon=="file murottal shubuh") {
      Serial.println("File murottal shubuh");
      Serial.println("Alamat EEPROM digunakan 123.");

      int fileMurottal;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          fileMurottal = strCon.toInt();
          Serial.println(fileMurottal);
          
          if (fileMurottal > 0 && fileMurottal < 256)
          {
            writeEEPROM(123, fileMurottal);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, 1-255.");
          }
        }
      }
    }
    else if (strCon=="file murottal dhuhur") {
      Serial.println("File murottal dhuhur");
      Serial.println("Alamat EEPROM digunakan 124.");

      int fileMurottal;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          fileMurottal = strCon.toInt();
          Serial.println(fileMurottal);
          
          if (fileMurottal > 0 && fileMurottal < 256)
          {
            writeEEPROM(124, fileMurottal);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, 1-255.");
          }
        }
      }
    }
    else if (strCon=="file murottal ashar") {
      Serial.println("File murottal ashar");
      Serial.println("Alamat EEPROM digunakan 125.");

      int fileMurottal;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          fileMurottal = strCon.toInt();
          Serial.println(fileMurottal);
          
          if (fileMurottal > 0 && fileMurottal < 256)
          {
            writeEEPROM(125, fileMurottal);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, 1-255.");
          }
        }
      }
    }
    else if (strCon=="file murottal maghrib") {
      Serial.println("File murottal maghrib");
      Serial.println("Alamat EEPROM digunakan 126.");

      int fileMurottal;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          fileMurottal = strCon.toInt();
          Serial.println(fileMurottal);
          
          if (fileMurottal > 0 && fileMurottal < 256)
          {
            writeEEPROM(126, fileMurottal);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, 1-255.");
          }
        }
      }
    }
    else if (strCon=="set juzz mulai") {
      Serial.println("File murottal otomatis.");
      Serial.println("Alamat EEPROM digunakan 127.");

      int fileMurottal;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          fileMurottal = strCon.toInt();
          Serial.println(fileMurottal);
          
          if (fileMurottal > 0 && fileMurottal < 31)
          {
            writeEEPROM(127, fileMurottal);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, 1-30.");
          }
        }
      }
    }
    else if (strCon=="play mp3") {
      Serial.println("Playing MP3");
      Serial.println("Masukkan ID File: 1-9999 ==> 1-255");

      int fileMurottal;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          fileMurottal = strCon.toInt();
          Serial.println(fileMurottal);
          
          if (fileMurottal > 0 && fileMurottal < 256)
          {
            Serial.print("Play MP3, ID File: ");
            Serial.println(fileMurottal);
            //mp3_play(fileMurottal);
            ABLedDFPlayer.stop();
            delay(200);
            ABLedDFPlayer.play(fileMurottal);
            delay(200);

            Serial.print("Current File Number:");
            Serial.println(ABLedDFPlayer.readCurrentFileNumber());
            Serial.print("Pin Busy: ");
            Serial.println(digitalRead(PIN_BUSY));

            break;
          }
          else
          {
            Serial.println("Masukkan format bilangan yang benar, 1-255.");
          }
        }
      }
    }
    else if (strCon=="stop mp3") {
      Serial.println("Stopping MP3");
      ABLedDFPlayer.stop();
      flagPlayMP3 = 0;

      Serial.print("Pin Busy: ");
      Serial.println(digitalRead(PIN_BUSY));
    }
    else if (strCon=="volume mp3") {
      Serial.println("Set volume MP3");
      Serial.println("Masukkan nilai level volume: 0-30.");

      int levelVolume;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          levelVolume = strCon.toInt();

          if (levelVolume >= 0 && levelVolume <31)
          {
              ABLedDFPlayer.volume(levelVolume);
              Serial.print("Level volume: ");
              Serial.println(levelVolume);

              break;
          }
          else
          {
            Serial.println("Masukkan nilai yang benar: 0-30");
          }
        }
      }
    }
    else if (strCon=="kontrol ampli murottal") {
      Serial.println("Kontrol On/Of Ampli dan Murottal");
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          Serial.println(strCon);

          int idNWS, idFWS, idNWD, idFWD, idNWA, idFWA, idNWM, idFWM, idNWI, idFWI, idSWS, idSWD, idSWA, idSWM;
          int ANWS, AFWS, ANWD, AFWD, ANWA, AFWA, ANWM, AFWM, ANWI, AFWI;
          int MSWS, MSWD, MSWA, MSWM;
          
          idNWS = strCon.indexOf("/");
          idFWS = strCon.indexOf("/", idNWS + 1);
          idNWD = strCon.indexOf("/", idFWS + 1);
          idFWD = strCon.indexOf("/", idNWD + 1);
          idNWA = strCon.indexOf("/", idFWD + 1);
          idFWA = strCon.indexOf("/", idNWA + 1);
          idNWM = strCon.indexOf("/", idFWA + 1);
          idFWM = strCon.indexOf("/", idNWM + 1);
          idNWI = strCon.indexOf("/", idFWM + 1);
          idFWI = strCon.indexOf("/", idNWI + 1);
          idSWS = strCon.indexOf("/", idFWI + 1);
          idSWD = strCon.indexOf("/", idSWS + 1);
          idSWA = strCon.indexOf("/", idSWD + 1);
          idSWM = strCon.indexOf("/", idSWA + 1);
          
          ANWS = strCon.substring(0, idNWS).toInt();  //waktu on ampli shubuh
          AFWS = strCon.substring(idNWS + 1, idFWS).toInt();  //waktu off ampli shubuh
          ANWD = strCon.substring(idFWS + 1, idNWD).toInt();  //waktu on ampli dhuhur
          AFWD = strCon.substring(idNWD + 1, idFWD).toInt();  //waktu off ampli dhuhur
          ANWA = strCon.substring(idFWD + 1, idNWA).toInt();  //waktu on ampli ashar
          AFWA = strCon.substring(idNWA + 1, idFWA).toInt();  //waktu off ampli ashar
          ANWM = strCon.substring(idFWA + 1, idNWM).toInt();  //waktu on ampli maghrib
          AFWM = strCon.substring(idNWM + 1, idFWM).toInt();  //waktu off ampli maghrib
          ANWI = strCon.substring(idFWM + 1, idNWI).toInt();  //waktu on ampli isya'
          AFWI = strCon.substring(idNWI + 1, idFWI).toInt();  //waktu off ampli isya'
          MSWS = strCon.substring(idFWI + 1, idSWS).toInt();  //waktu stop murottal shubuh
          MSWD = strCon.substring(idSWS + 1, idSWD).toInt();  //waktu stop murottal dhuhur
          MSWA = strCon.substring(idSWD + 1, idSWA).toInt();  //waktu stop murottal ashar
          MSWM = strCon.substring(idSWA + 1, idSWM).toInt();  //waktu stop murottal maghrib

          Serial.println("Hasil pemecahan stringwaktu on/off ampli dan murottal: ");
          Serial.println(ANWS);
          Serial.println(AFWS);
          Serial.println(ANWD);
          Serial.println(AFWD);
          Serial.println(ANWA);
          Serial.println(AFWA);
          Serial.println(ANWM);
          Serial.println(AFWM);
          Serial.println(ANWI);
          Serial.println(AFWI);
          Serial.println(MSWS);
          Serial.println(MSWD);
          Serial.println(MSWA);
          Serial.println(MSWM);

          /*
          if (fileMurottal > 0 && fileMurottal < 256)
          {
            writeEEPROM(126, fileMurottal);
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
            break;
          }
          */

            writeEEPROM(128, ANWS);
            writeEEPROM(129, AFWS);
            writeEEPROM(130, ANWD);
            writeEEPROM(131, AFWD);
            writeEEPROM(132, ANWA);
            writeEEPROM(133, AFWA);
            writeEEPROM(134, ANWM);
            writeEEPROM(135, AFWM);
            writeEEPROM(136, ANWI);
            writeEEPROM(137, AFWI);
            writeEEPROM(138, MSWS);
            writeEEPROM(139, MSWD);
            writeEEPROM(140, MSWA);
            writeEEPROM(141, MSWM);
            
            EEPROM.commit();

            Serial.println("EEPROM Committed");
            loadDataEEPROM();
            
          break;
        }
      }
    }
    else if (strCon=="on ampli manual") 
    {
      if (digitalRead(_RELAY) == 1)
      {
        Serial.println("on ampli manual");
        
        nyalakanAmpli();
        flagCekPlayMP3 = 1;
      }
      else
      {
        ABLedDFPlayer.stop();
        delay(200);
        
        flagCekPlayMP3 = 1;
      }
    }
    else if (strCon=="off ampli manual") {
      if (digitalRead(_RELAY) == 0)
      {
        Serial.println("off ampli manual");
        
        matikanAmpli();
        flagCekPlayMP3 = 0;
      }
    }
    else if (strCon=="play murottal manual") {
      
        int fileMurottal = random(1,30);
      
        while(true)
        { 
          if (udp.parsePacket()) 
          {
            remoteIp = udp.remoteIP();
            len = udp.read(packetBuffer, 255);
            if (len > 0) packetBuffer[len] = 0;
            strCon = packetBuffer;
           
            if (strCon == "stop murottal manual")
            {
              Serial.println("stop murottal manual");
              ABLedDFPlayer.stop();
              delay(200);

              break;
            }
          }
          

          if (digitalRead(_RELAY) == 0) //relay harus nyala / 0
          {
            if (digitalRead(PIN_BUSY) == 1) //Kalau MP3 Player sedang off / stop play / idle
            {
               ABLedDFPlayer.play(fileMurottal);
               delay(200);     

               fileMurottal++;

               //if (fileMurottal > 30)
               //{
               //   fileMurottal = 1;
               //}
            }
            
          }

          delay(200);
          //break;
        }
    }
    else if (strCon=="stop murottal manual") {
      if (digitalRead(_RELAY) == 0)
      {
        Serial.println("stop murottal manual");
        if (digitalRead(PIN_BUSY) == 0) //Kalau MP3 Player sedang on
        {
            ABLedDFPlayer.stop();
            delay(200);
         }
      }
    }
    else if (strCon=="set vol") {
      Serial.println("Set volume MP3");

      int levelVolume;
      
      while(true)
      { 
        if (udp.parsePacket()) 
        {
          remoteIp = udp.remoteIP();
          len = udp.read(packetBuffer, 255);
          if (len > 0) packetBuffer[len] = 0;
          strCon = packetBuffer;
         
          levelVolume = strCon.toInt();
          
          if (levelVolume >= 0 && levelVolume <31)
          {
              ABLedDFPlayer.volume(levelVolume);

              Serial.print("Volume sudah diset ke: ");
              Serial.print(strCon);

              writeEEPROM(142, levelVolume);
              EEPROM.commit();
              Serial.println("EEPROM Committed. Volume saved in EEPROM.");
              //loadDataEEPROM();

              break;
          }
          else
          {
            Serial.println("Masukkan nilai yang benar: 0-30");
          }
        }
      }
    }
    else if (strCon=="nyalakan ampli") {
      if (digitalRead(_RELAY) == 1)
      {
        Serial.println("Ampli dinyalakan");
        nyalakanAmpli();
      }
    }
    else if (strCon=="matikan ampli") {
      if (digitalRead(_RELAY) == 0)
      {
        Serial.println("Ampli dimatikan");
        matikanAmpli();
      }
    }
    else if (strCon=="tes suara angka") {
      Serial.println("tes suara angka");
      
      tesSuaraAngka();
    }
    else if (strCon=="restart") {
      ESP.restart();
    }
  }
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

//----------------------------------------Procedure for receiving text / messages from the sender-------------------------------------------------------------------------------------------//
void playMP3(int idMurottal) {
  //mp3_play (idMurottal); //memainkan lagu 1 pada folder mp3 yang sudah direname dengan nama 0001.mp3
  //delay (10000); //jeda 10 detik
  //mp3_next (); //memainkan lagu 2 dengan mode next
  //delay (10000);
  //mp3_play (idMurottal); //memainkan lagu 3
  //delay (6000);

  //Sketch from: https://www.nyebarilmu.com/tutorial-mengakses-module-mp3-dfplayer-mini/?fbclid=IwAR0b0fNagVHdLAKPjjR_crMkXfdeIf9Y9McVnNZzBmFOVlnDO0IH_zVg2z4
  //Serial.println("Stop");
  //mp3_stop ();
  //Serial.print("Busy: ");
  //Serial.println(digitalRead(PIN_BUSY));
  //delay(500);
  //Serial.println("play next");
  //mp3_next ();
  //Serial.print("Busy: ");
  //Serial.println(digitalRead(PIN_BUSY));
  //delay (12000);
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

//---------------------------------------- Read eeprom for ssid and pass
void readSSIDnPWD()
{
  ssidSaved = "";
  passwordSaved = "";
  
  for (int i = 0; i < 32; ++i)
  {
    ssidSaved += char(EEPROM.read(i));
  }
  
  for (int i = 32; i < 96; ++i)
  {
    passwordSaved += char(EEPROM.read(i));
  }
   
}


//---------------------------------------- Read eeprom for ssid and pass

char readEEPROM(int addr)
{
  return char(EEPROM.read(addr));
}

void writeEEPROM(int addr, int nilai)
{
  if (addr == 127 && nilai == 31)
  {
    Serial.println("Write to 127, address memory for juzz, Juzz wil be reset to 1...");
    EEPROM.write(addr, 1);  //Juzz kembali ke juzz 1
    loadDataEEPROM();
    Serial.println("Juzz success reset to 1.");
  }
  else
  {
    Serial.print("Write to ");
    Serial.print(addr);
    Serial.print(" memory address with ");
    Serial.println(nilai);
    EEPROM.write(addr, nilai); 
    Serial.println("Write success");
  }
}

void writeEEPROM(int addr, char nilai)
{
  EEPROM.write(addr, nilai);
}


void writeEEPROM(int addr, String str)
{
  if (addr == 0 and str.length() <= 32)  //store ssid
  {
    for (int i=addr; i<32; i++)
    {
      if (addr < str.length())
      {
        EEPROM.write(addr, str[i]);
        //Serial.println(str[i]);
        //delay(10);
      }
      else
      {
        EEPROM.write(addr, 0xFF);
      }
      
      addr++;
    }
  }
  else if (addr == 32 and str.length() <= 96) //store password
  {
    for (int i=addr; i<96; i++)
    {
      if (addr < str.length())
      {
        EEPROM.write(addr, str[i]);
        Serial.println(str[i]);
        delay(10);
      }
      else
      {
        EEPROM.write(addr, 0xFF);
      }
      
      addr++;
    }
  }
  else
  {
    for (int i=addr; i<str.length(); i++)
    {
      char aChar = i;
      Serial.print("Writing ");
      Serial.print(str[i]);
      Serial.print(" on EEPROM at address ");
      Serial.println(aChar);
      EEPROM.write(addr, str[i]);
      addr++;
    }
  }
  
    EEPROM.commit(); 
}


B4A Auto Murottal Remote (Main Page):

  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
#Region  Project Attributes 
	#ApplicationLabel: AB Led Auto Murottal
	#VersionCode: 1
	#VersionName: 
	'SupportedOrientations possible values: unspecified, landscape or portrait.
	#SupportedOrientations: portrait
	#CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
	#FullScreen: True
	#IncludeTitle: False
#End Region

Sub Process_Globals
	Public ActionBarHomeClicked As Boolean
	
	'The UdpS and UdpP variables are shared with UDPControlLED module so that they use the Public declaration, if not shared then use the Pirvate declaration
	Public UdpS As UDPSocket
	Public UdpP As UDPPacket
	Public ShrIP, ShrPort As String
	Private server As ServerSocket
	
	Private Timer1 As Timer
End Sub

Sub Timer1_Tick
	lblJam.Text = time
	lblTanggal.Text = date
End Sub

Sub Globals
	'Private btnSyncJam As Button
	'Private btnSyncTgl As Button
	
	Public Jam() As String
	Jam = Array As String("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23")
	 
	Public Menit() As String
	Menit = Array As String("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "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")
	
	Public Detik() As String
	Detik = Array As String("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "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")
	
	Public Hari() As String = Array As String("Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu")
	
	
	Private rbManual As RadioButton
	Private rbOtomatis As RadioButton
	Private btnKeluar As Button
	Private btnSyncHariM As Button
	Private btnSyncJam As Button
	Private btnSyncJamM As Button
	Private btnSyncTglM As Button
	Private cmbDetik As Spinner
	Private cmbHari As Spinner
	Private cmbJam As Spinner
	Private cmbMenit As Spinner
	Private Panel4 As Panel
	Private Panel5 As Panel
	Private txtTanggal As EditText
	Private btnSyncTgl As Button
	Private lblJam As Label
	Private lblTanggal As Label
	
	Private lblMyIP As Label
	
	Dim destIP, destPort As String
	Dim strCmd As String
	
	Private Label7 As Label
	Private btnRetrieveIPKntr As Button
	Private txtDestIP As EditText
	Private txtDestPort As EditText
	Private btnAturNFAM As Button
	
	Private Label3 As Label
	Private Label1 As Label
	Private Label10 As Label
	Private Label11 As Label
	Private Label12 As Label
	Private Label13 As Label
	Private Label2 As Label
	Private Label4 As Label
	Private Label5 As Label
	Private Label6 As Label
	Private Label8 As Label
	Private Label9 As Label
	Private lbl1 As Label
	Private Panel1 As Panel
	Private Panel2 As Panel
	Private Panel3 As Panel
	Private Panel6 As Panel
	Private Panel7 As Panel
	
	'Private pnl2SY As Int = ((80/853)*100)
	'Private pnl2SX As Double = 100%x
	
	Private lblVolume As Label
	Private btnVolume As Button
	Private txtVolume As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
	If FirstTime Then
		UdpS.Initialize("UdpSEvent", 2000, 1024)
	End If
	
	Dim pm As B4XPagesManager
	pm.Initialize(Activity)
	Activity.LoadLayout("AMRMain")
	
	lblMyIP.Text = "IP Address : " & server.GetMyWifiIP
	txtDestIP.Text = ShrIP
	txtDestPort.Text = ShrPort
	
	loadComboBoxItems
	rbOtomatis.Checked = True
	rbOtomatis_CheckedChange(True)
	
	Timer1.Initialize("Timer1",1000)
	Timer1.Enabled = True
	
	btnSyncHariM.Enabled = False
	cmbHari.Enabled = False
	btnSyncHariM.Visible = False
	cmbHari.Visible = False
	Label7.Visible = False
	
	Label3.Width = 35%x
	rbOtomatis.Width = 20%x
	rbManual.Width = 20%x
End Sub

'Template version: B4A-1.01
#Region Delegates

Sub Activity_ActionBarHomeClick
	ActionBarHomeClicked = True
	B4XPages.Delegate.Activity_ActionBarHomeClick
	ActionBarHomeClicked = False
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
	Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Sub Activity_Resume
	B4XPages.Delegate.Activity_Resume
	
	AdjustScreenRes
End Sub

Sub Activity_Pause (UserClosed As Boolean)
	B4XPages.Delegate.Activity_Pause
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
	B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub

Sub Create_Menu (Menu As Object)
	B4XPages.Delegate.Create_Menu(Menu)
End Sub

#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
	 processBA.raiseEvent(null, "create_menu", menu);
	 return true;
	
}
#End If
#End Region

'Program code should go into B4XMainPage and other pages.

Sub AdjustScreenRes
	Panel1.SetLayout(0,0,100%x,100%y)
	
	Panel2.SetLayout(0, 0, 100%x, 9.378%y)
	lbl1.SetLayout(0, 3.516998828%y, 100%x, 5.861664713%y)
	Label1.SetLayout(0, 0, 25%x, 3.516998828%y)
	Label2.SetLayout(50%x, 0, 25%x, 3.516998828%y)
	Label2.Left = 100%x - Label2.Width
	
	Panel3.SetLayout(0, 9.37866354%y, 100%x, 48.06565064%y)
	Label3.SetLayout(2.083333333%x, 0, 39.58333333%x, 4.68933177%y)
	rbOtomatis.SetLayout(41.45833333%x, 0, 20.83333333%x, 4.68933177%y)
	rbManual.SetLayout(63.75%x, 0, 20.83333333%x, 4.68933177%y)
	Label3.TextSize = 14
	rbOtomatis.TextSize = 10
	rbManual.TextSize = 10
	'panel4
	Panel4.SetLayout(0, 4.689%y, 100%x, 18.757%y)
	lblJam.SetLayout(0, 2.344665885%y, 33.33333333%x, 5.861664713%y)
	lblTanggal.SetLayout(0, 2.344665885%y, 41.66666667%x, 5.861664713%y)
	lblTanggal.Left = 100%x - lblTanggal.Width
	lblJam.TextSize = 24
	lblTanggal.TextSize = 14
	btnSyncJam.SetLayout(4dip, Panel4.Height - btnSyncJam.Height, 31.25%x, 7.033997655%y)
	btnSyncTgl.SetLayout(0, Panel4.Height - btnSyncTgl.Height, 31.25%x, 7.033997655%y)
	btnSyncTgl.Left = 100%x - btnSyncTgl.Width - 4dip	'after set its layout, re set the left position
	btnSyncJam.TextSize = btnSyncJam.TextSize - ((100%x/480) + 1)
	btnSyncTgl.TextSize = btnSyncTgl.TextSize - ((100%x/480) + 1)
	'panel5
	Panel5.SetLayout(0, 23.44665885%y, 100%x, 21.10199297%y)
	Label4.SetLayout(8dip, 0, 12.5%x, 3.516998828%y)
	Label5.SetLayout(Label4.Left + Label4.Width + 8dip, 0, 12.5%x, 3.516998828%y)
	Label6.SetLayout(Label5.Left + Label5.Width + 8dip, 0, 12.5%x, 3.516998828%y)
	Label4.TextSize = Label4.TextSize - ((100%x/480) + 1)
	Label5.TextSize = Label5.TextSize - ((100%x/480) + 1)
	Label6.TextSize = Label6.TextSize - ((100%x/480) + 1)
	cmbJam.SetLayout(4dip, Label4.Height + 1dip, 22%x, 4.68933177%y)
	cmbMenit.SetLayout(cmbJam.Left + cmbJam.Width + 10dip, Label4.Height + 1dip, 22%x, 4.68933177%y)
	cmbDetik.SetLayout(cmbMenit.Left + cmbMenit.Width + 10dip , Label4.Height + 1dip, 22%x, 4.68933177%y)
	cmbJam.TextSize = cmbJam.TextSize - ((100%x/480) + 1)
	cmbMenit.TextSize = cmbMenit.TextSize - ((100%x/480) + 1)
	cmbDetik.TextSize = cmbDetik.TextSize - ((100%x/480) + 1)
	Label4.Left = cmbJam.Left
	Label5.Left = cmbMenit.Left
	Label6.Left = cmbDetik.Left
	'btnSyncJamM.SetLayout(100%x - btnSyncJamM.Width, 0, 16.66666667%x, 9.37866354%y)
	btnSyncJamM.SetLayout(cmbDetik.Left + cmbDetik.Width + 2dip, 0, 16.66666667%x, 9.37866354%y)
	btnSyncJamM.TextSize = btnSyncJamM.TextSize - ((100%x/480) + 1)
	Label8.SetLayout(cmbJam.Left, 9.37866354%y, 16.66666667%x, 4.68933177%y)
	Label8.TextSize = Label8.TextSize - ((100%x/480) + 1)
	txtTanggal.SetLayout(Label8.Left + Label8.Width, Label8.Top, 26.875%x, 4.68933177%y)
	txtTanggal.TextSize = txtTanggal.TextSize - ((100%x/480) + 1)
	'btnSyncTglM.SetLayout(Label8.Left, 15.24032825%y, 43.75%x, 5.861664713%y)
	btnSyncTglM.SetLayout(Label8.Left, txtTanggal.Top + txtTanggal.Height + 1dip, 43.75%x, 5.861664713%y)
	
	Panel6.SetLayout(0, 57.44431419%y, 100%x, 9.026963658%y)
	'Panel6.SetLayout(0, Panel3.Top + Panel3.Width, 100%x, 9.026963658%y)
	btnAturNFAM.SetLayout(0, 0, 62.5%x, 5.50996483%y)
	btnAturNFAM.Left = (Panel6.Width - btnAturNFAM.Width) / 2
	btnAturNFAM.Top = (Panel6.Height - btnAturNFAM.Height) / 2
	btnAturNFAM.TextSize = btnAturNFAM.TextSize - ((100%x/480) + 1)
	
	'Panel7.SetLayout(0, 66.82297773%y, 100%x, 26.6119578%y)
	Panel7.SetLayout(0, Panel6.Top + Panel6.Height, 100%x, 26.6119578%y)
	lblMyIP.SetLayout(0, 0, 91.66666667%x, 4.68933177%y)
	lblMyIP.TextSize = lblMyIP.TextSize - ((100%x/480) + 1)
	lblMyIP.Left = (Panel7.Width - lblMyIP.Width) / 2
	'lblMyIP.Top = Panel7.Top
	Label13.SetLayout(0, lblMyIP.Top + lblMyIP.Height, Panel7.Width, 4.68933177%y)
	Label13.TextSize = Label13.TextSize - ((100%x/480) + 1)
	Label11.SetLayout(4.166666667%x, 9.37866354%y, 25%x, 4.68933177%y)
	Label11.TextSize = Label11.TextSize - ((100%x/480) + 1)
	txtDestIP.SetLayout(33.33333333%x, Label11.Top, 33.33333333%x, 4.68933177%y)
	txtDestIP.TextSize = txtDestIP.TextSize - ((100%x/480) + 1)
	Label12.SetLayout(16.66666667%x, 14.06799531%y, 12.5%x, 4.68933177%y)
	Label12.TextSize = Label12.TextSize - ((100%x/480) + 1)
	txtDestPort.SetLayout(33.33333333%x, 14.06799531%y, 16.66666667%x, 4.68933177%y)
	txtDestPort.TextSize = txtDestPort.TextSize - ((100%x/480) + 1)
	btnRetrieveIPKntr.SetLayout(70.83333333%x, 10.55099648%y, 22.91666667%x, 7.971864009%y)
	btnRetrieveIPKntr.TextSize = btnRetrieveIPKntr.TextSize - ((100%x/480) + 1)
	btnKeluar.SetLayout(0, 19.92966002%y, 95.83333333%x, 5.50996483%y)
	btnKeluar.Left = (Panel7.Width - btnKeluar.Width) / 2
	btnKeluar.TextSize = btnKeluar.TextSize - ((100%x/480) + 1)
	
	Label9.SetLayout(0, 0, 100%x, 3.516998828%y)
	Label9.Top = 100%y - Label9.Height
	Label10.SetLayout(0,0, 100%x, 2.696365768%y)
	Label10.Top = 100%y - Label9.Height - Label10.Height
	Label9.TextSize = Label9.TextSize - ((100%x/480) + 1)
	Label10.TextSize = Label10.TextSize - ((100%x/480) + 1)
	
	lblVolume.SetLayout(41.5%x, 5.68933177%y, 18.75%x, 3.516998828%y)
	lblVolume.TextSize = lblVolume.TextSize - ((100%x/480) + 1)
	txtVolume.SetLayout(41.5%x, 8.206330598%y, 18.75%x, 4.68933177%y)
	txtVolume.TextSize = txtVolume.TextSize - ((100%x/480) + 1)
	btnVolume.SetLayout(42.58333333%x, 12.48182884%y, 14.58333333%x, 4.68933177%y)
	btnVolume.TextSize = btnVolume.TextSize - ((100%x/480) + 1)
	
End Sub

Sub btnSyncTgl_Click
	'If txtDestinationIP.Text = "" Or txtDestinationPort.Text = "" Then
	'ToastMessageShow("Destination IP and Destination Port cannot be empty !!!",False)
	'Return
	'End If
	
	destIP = "192.168.4.1"
	destPort = "2000"
	
	If rbOtomatis.Checked = True Then
		UdpP.Initialize("set date".GetBytes("ASCII"), destIP, destPort)
		UdpS.Send(UdpP)
	
		Dim hariTanggal() As String = Regex.Split(",", lblTanggal.Text)
		'ToastMessageShow(hariTanggal(0), False)
		'ToastMessageShow(Regex.Replace("-", (hariTanggal(1).Trim), ""), False)
	
		UdpP.Initialize(Regex.Replace("-", (hariTanggal(1).Trim), "").GetBytes("ASCII"), destIP, destPort)
		UdpS.Send(UdpP)
	End If
End Sub

Sub btnSyncJam_Click
	'If txtDestinationIP.Text = "" Or txtDestinationPort.Text = "" Then
		'ToastMessageShow("Destination IP and Destination Port cannot be empty !!!",False)
		'Return
	'End If
	
	If rbOtomatis.Checked = True Then
		destIP = "192.168.4.1"
		destPort = "2000"
	
		UdpP.Initialize("set time".GetBytes("ASCII"), destIP, destPort)
		UdpS.Send(UdpP)
	
		Dim Jam() As String = Regex.Split(":", lblJam.Text)
		'ToastMessageShow(Jam(0) & Jam(1) & Jam(2), False)
		UdpP.Initialize((Jam(0) & Jam(1) & Jam(2)).GetBytes("ASCII"), destIP, destPort)
		UdpS.Send(UdpP)
	
		'ToastMessageShow(Regex.Replace(":", lblJam.Text, "$0"), False)
		'UdpP.Initialize(Regex.Replace(":", lblJam.Text, "$0").GetBytes("ASCII"), destIP, destPort)
		'UdpS.Send(UdpP)
	End If
End Sub


'Sub UdpSEvent_PacketArrived (Packet As UDPPacket)
	'txtReceiver.Text = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "ASCII")
'End Sub


Sub rbOtomatis_CheckedChange(Checked As Boolean)
	Try
		Panel4.Enabled = True
		Panel4.Visible = True
		Panel5.Enabled = False
		Panel5.Visible = False
		
		cmbJam.Enabled = False
		cmbMenit.Enabled = False
		cmbDetik.Enabled = False
		cmbHari.Enabled = False
		btnSyncTglM.Enabled = False
		btnSyncHariM.Enabled = False
		txtTanggal.Enabled = False
		btnSyncJamM.Enabled = False
		
		btnSyncJam.Enabled = True
		btnSyncTgl.Enabled = True
	Catch
		Log(LastException)
	End Try
End Sub

Sub rbManual_CheckedChange(Checked As Boolean)
	Try
		Panel4.Enabled = False
		Panel4.Visible = False
		Panel5.Enabled = True
		Panel5.Visible = True
		
		cmbJam.Enabled = True
		cmbMenit.Enabled = True
		cmbDetik.Enabled = True
		cmbHari.Enabled = True
		btnSyncTglM.Enabled = True
		btnSyncHariM.Enabled = True
		txtTanggal.Enabled = True
		btnSyncJamM.Enabled = True
		
		
		btnSyncJam.Enabled = False
		btnSyncTgl.Enabled = False
		
	Catch
		Log(LastException)
	End Try
End Sub

Sub btnSyncTglM_Click
	Try
		Dim tglFrmt() As String = Regex.Split("/", txtTanggal.Text)
		'ToastMessageShow (tglFrmt(0) & tglFrmt(1) & tglFrmt(2), False)
		
		'Cek Tanggal
		If IsNumber(tglFrmt(0)) Then
			Dim tglNum As Int = tglFrmt(0)
			If ( tglNum > 0 And tglNum < 32) = True Then
				
				'Cek Bulan
				If IsNumber(tglFrmt(1)) Then
					Dim blnNum As Int = tglFrmt(1)
					If ( blnNum > 0 And blnNum < 13) = True Then
						
						'Cek Tahun
						If IsNumber(tglFrmt(2)) Then
							Dim thnNum As Int = tglFrmt(2)
							If ( thnNum > 999 And blnNum < 3001) = True Then
								'Proses kirim data ke kontroler / auto murottal
								sendCmnd("set date")
								'sendCmnd(tglNum & blnNum & thnNum)
								sendCmnd(tglFrmt(0) & tglFrmt(1) & tglFrmt(2))
							Else
								ToastMessageShow("Masukkan range tahun yang benar (1000-3000)", False)	
							End If
						Else
							ToastMessageShow("Masukkan nilai tahun yang benar (1000-3000)", False)
						End If
					Else
						ToastMessageShow("Masukkan range bulan yang benar (1-12)", False)
					End If
				Else
					ToastMessageShow("Masukkan nilai bulan yang benar (1-12)", False)
				End If
			Else
				ToastMessageShow("Masukkan range tanggal yang benar (1-31)", False)
			End If
		Else
			ToastMessageShow("Masukkan nilai tanggal yang benar (1-31)", False)
		End If
	Catch
		Log(LastException)
	End Try
End Sub

Sub btnSyncJamM_Click
	Try
		sendCmnd("set time")
		sendCmnd(cmbJam.SelectedItem & cmbMenit.SelectedItem & cmbDetik.SelectedItem)
	Catch
		Log(LastException)
	End Try	
End Sub

Sub btnSyncHariM_Click
	Try
		sendCmnd("set day")
		sendCmnd(konversiHari2(cmbHari.SelectedItem))
	Catch
		Log(LastException)
	End Try
End Sub

Sub btnKeluar_Click
	Try
		Activity.Finish()
	Catch
		Log(LastException)
	End Try
End Sub

Sub time As String
	Dim time_up As Long = DateTime.Now
	DateTime.TimeFormat = "HH:mm:ss"
	DateTime.SetTimeZone(7)
	Dim str_time_up As String = DateTime.Time(time_up)
	
	Return str_time_up
End Sub

Sub date As String
	Dim date_up As Long = DateTime.Now
	DateTime.DateFormat = "dd-MM-yyyy"
	DateTime.SetTimeZone(7)
	Dim str_date_up As String = konversiHari(DateTime.GetDayOfWeek(date_up)) & ", " & DateTime.Date(date_up) & "
	
	Return str_date_up
End Sub

Sub konversiHari(hr As Int) As String
	Select hr
		Case 1:
			Return "Minggu"
		Case 2:
			Return "Senin"
		Case 3:
			Return "Selasa"
		Case 4:
			Return "Rabu"
		Case 5:
			Return "Kamis"
		Case 6:
			Return "Jum'at"
		Case 7:
			Return "Sabtu"
	End Select
End Sub

Sub konversiHari2(hr As String) As Int
	Select hr
		Case "Minggu":
			Return 1
		Case "Senin":
			Return 2
		Case "Selasa":
			Return 3
		Case "Rabu":
			Return 4
		Case "Kamis":
			Return 5
		Case "Jum'at":
			Return 6
		Case "Sabtu":
			Return 7
	End Select
End Sub

Sub loadComboBoxItems()
	Try
		cmbJam.AddAll(Jam)
		cmbMenit.AddAll(Menit)
		cmbDetik.AddAll(Detik)
		
		cmbHari.AddAll(Hari)
		'cmbOnWD.AddAll(Menit)
		
		cmbJam.SelectedIndex = 0
		cmbMenit.SelectedIndex = 0
		cmbDetik.SelectedIndex = 0
		cmbHari.SelectedIndex = 0
		'cmbOnWD.SelectedIndex = 0
	Catch
		Log(LastException)
	End Try
End Sub

Sub sendCmnd (strCmnd As String)
	Try
		
		destIP = "192.168.4.1"
		destPort = "2000"
	
		UdpP.Initialize(strCmnd.GetBytes("ASCII"), destIP, destPort)
		UdpS.Send(UdpP)
		Wait(200)
	Catch
		Log(LastException)
	End Try
End Sub



Sub btnRetrieveIPKntr_Click
	sendCmnd("give me your ip")
	'sendCmnd(server.GetMyWifiIP)
	'Wait(200)
End Sub

Sub UdpSEvent_PacketArrived (Packet As UDPPacket)
	Try
		ToastMessageShow("Sedang menerima paket.", False)
		
		Dim rcvStr As String = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "ASCII")
		'ToastMessageShow(rcvStr, False)
	
		If rcvStr.SubString2(0,2) = "ip" Then
			txtDestIP.Text = rcvStr.SubString(2)
		End If
	
		If rcvStr.SubString2(0,2) = "pt" Then
			txtDestPort.Text = rcvStr.SubString(2)
		End If
		
		ToastMessageShow("Selesai menerima paket.", False)
	Catch
		Log(LastException)
	End Try
End Sub

Sub btnAturNFAM_Click
	Try
		If txtDestIP.Text = "" Or txtDestPort.Text = "" Then
			ToastMessageShow("Tekan tombol Retrieve IP Kontroler terlebih dahulu!", False)
		Else
			ShrIP = txtDestIP.Text
			ShrPort = txtDestPort.Text
			StartActivity(settingMurottal)
			Activity.Finish
		End If
	Catch
		Log(LastException)
	End Try
End Sub

Sub Wait(ms As Int)
	Try
		Dim n As Long = DateTime.Now + ms
		Do While DateTime.Now < n
		Loop
	Catch
		ToastMessageShow(LastException, False)
	End Try
End Sub

Sub btnVolume_Click
	Try
		Dim numVol As Int = txtVolume.Text
		
		If (numVol < 0 Or numVol > 30) Then
			ToastMessageShow("Peringatan: Masukkan nilai volume 0-30", False)
		Else
			sendCmnd("set vol")
			sendCmnd(txtVolume.Text)
		End If
	Catch
		ToastMessageShow(LastException, False)
	End Try
End Sub


B4A Auto Murottal Remote (Setting Page):

  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
#Region  Activity Attributes 
	#FullScreen: True
	#IncludeTitle: False
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Private btnKembali As Button
	Private btnKP As Button
	Private cbOA As CheckBox
	Private cbPM As CheckBox
	Private rbM As RadioButton
	Private rbO As RadioButton
	Private txtWAF As EditText
	Private txtWAN As EditText
	Private txtWAS As EditText
	Private txtWDF As EditText
	Private txtWDN As EditText
	Private txtWDS As EditText
	Private txtWIF As EditText
	Private txtWIN As EditText
	Private txtWIS As EditText
	Private txtWMF As EditText
	Private txtWMN As EditText
	Private txtWMS As EditText
	Private txtWSF As EditText
	Private txtWSN As EditText
	Private txtWSS As EditText
	Private Label1 As Label
	Private Label10 As Label
	Private Label11 As Label
	Private Label12 As Label
	Private Label13 As Label
	Private Label14 As Label
	Private Label15 As Label
	Private Label16 As Label
	Private Label17 As Label
	Private Label18 As Label
	Private Label19 As Label
	Private Label2 As Label
	Private Label20 As Label
	Private Label21 As Label
	Private Label22 As Label
	Private Label23 As Label
	Private Label24 As Label
	Private Label25 As Label
	Private Label26 As Label
	Private Label27 As Label
	Private Label28 As Label
	Private Label29 As Label
	Private Label3 As Label
	Private Label30 As Label
	Private Label31 As Label
	Private Label32 As Label
	Private Label33 As Label
	Private Label34 As Label
	Private Label36 As Label
	Private Label37 As Label
	Private Label39 As Label
	Private Label4 As Label
	Private Label41 As Label
	Private Label5 As Label
	Private Label6 As Label
	Private Label7 As Label
	Private Label8 As Label
	Private Label9 As Label
	Private Panel1 As Panel
	Private Panel2 As Panel
	Private Panel3 As Panel
	Private Panel4 As Panel
	Private Panel6 As Panel
	Private txtVolume As EditText
	Private btnVolume As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
	'Do not forget to load the layout file created with the visual designer. For example:
	Activity.LoadLayout("SettingMurottal")
	
	rbO.Checked = True
	rbO_CheckedChange(True)
End Sub

Sub Activity_Resume
	'B4XPages.Delegate.Activity_Resume
	
	AdjustScreenRes
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub AdjustScreenRes
	Try
		Panel1.SetLayout(0,0,100%x,100%y)
		
		Label1.SetLayout(0,0,100%x, 4.68933177%y)
		Label1.TextSize = Label1.TextSize - ((100%x/480) + 1)
	
		Panel6.SetLayout(0, 4.68933177%y, 100%x, 56.27198124%y)
		Label9.SetLayout(0, 0, 100%x, 6.5%x)
		Label9.TextSize = Label9.TextSize - ((100%x/480) + 1)
		Label2.SetLayout(2.083333333%x, 4.68933177%y, 29.16666667%x, 4.68933177%y)
		Label2.TextSize  = Label2.TextSize - ((100%x/480) + 1)
		Label3.SetLayout(33.33333333%x, 4.68933177%y, 8.333333333%x, 4.68933177%y)
		Label3.TextSize  = Label3.TextSize - ((100%x/480) + 1)
		txtWSN.SetLayout(41.66666667%x, 4.68933177%y, 20.83333333%x, 4.68933177%y)
		txtWSN.TextSize = txtWSN.TextSize - ((100%x/480) + 1)
		Label4.SetLayout(62.5%x, 4.68933177%y, 40%x, 4.68933177%y)
		Label4.TextSize = Label4.TextSize - ((100%x/480) + 1)
		Label5.SetLayout(62.5%x, 9.37866354%y, 40%x, 4.68933177%y)
		Label5.TextSize = Label5.TextSize - ((100%x/480) + 1)
		txtWSF.SetLayout(41.66666667%x, 9.37866354%y, 20.83333333%x, 4.68933177%y)
		txtWSF.TextSize = txtWSF.TextSize - ((100%x/480) + 1)
		Label6.SetLayout(33.33333333%x, 9.37866354%y, 8.333333333%x, 4.68933177%y)
		Label6.TextSize = Label6.TextSize - ((100%x/480) + 1)
		
		Label10.SetLayout(2.083333333%x,15.24032825%y, 29.16666667%x, 4.68933177%y)
		Label10.TextSize  = Label10.TextSize - ((100%x/480) + 1)
		Label11.SetLayout(33.33333333%x, 15.24032825%y, 8.333333333%x, 4.68933177%y)
		Label11.TextSize  = Label11.TextSize - ((100%x/480) + 1)
		txtWDN.SetLayout(41.66666667%x, 15.24032825%y, 20.83333333%x, 4.68933177%y)
		txtWDN.TextSize = txtWDN.TextSize - ((100%x/480) + 1)
		Label12.SetLayout(62.5%x, 15.24032825%y, 40%x, 4.68933177%y)
		Label12.TextSize = Label12.TextSize - ((100%x/480) + 1)
		Label13.SetLayout(62.5%x, 19.92966002%y, 40%x, 4.68933177%y)
		Label13.TextSize = Label13.TextSize - ((100%x/480) + 1)
		txtWDF.SetLayout(41.66666667%x, 19.92966002%y, 20.83333333%x, 4.68933177%y)
		txtWDF.TextSize = txtWDF.TextSize - ((100%x/480) + 1)
		Label14.SetLayout(33.33333333%x, 19.92966002%y, 8.333333333%x, 4.68933177%y)
		Label14.TextSize = Label14.TextSize - ((100%x/480) + 1)
		
		Label15.SetLayout(2.083333333%x,25.79132474%y, 29.16666667%x, 4.68933177%y)
		Label15.TextSize  = Label15.TextSize - ((100%x/480) + 1)
		Label16.SetLayout(33.33333333%x, 25.79132474%y, 8.333333333%x, 4.68933177%y)
		Label16.TextSize  = Label16.TextSize - ((100%x/480) + 1)
		txtWAN.SetLayout(41.66666667%x, 25.79132474%y, 20.83333333%x, 4.68933177%y)
		txtWAN.TextSize = txtWAN.TextSize - ((100%x/480) + 1)
		Label17.SetLayout(62.5%x, 25.79132474%y, 40%x, 4.68933177%y)
		Label17.TextSize = Label17.TextSize - ((100%x/480) + 1)
		Label18.SetLayout(62.5%x, 30.48065651%y, 40%x, 4.68933177%y)
		Label18.TextSize = Label18.TextSize - ((100%x/480) + 1)
		txtWAF.SetLayout(41.66666667%x, 30.48065651%y, 20.83333333%x, 4.68933177%y)
		txtWAF.TextSize = txtWAF.TextSize - ((100%x/480) + 1)
		Label19.SetLayout(33.33333333%x, 30.48065651%y, 8.333333333%x, 4.68933177%y)
		Label19.TextSize = Label19.TextSize - ((100%x/480) + 1)
		
		Label21.SetLayout(2.083333333%x, 36.34232122%y, 29.16666667%x, 4.68933177%y)
		Label21.TextSize  = Label21.TextSize - ((100%x/480) + 1)
		Label20.SetLayout(33.33333333%x, 36.34232122%y, 8.333333333%x, 4.68933177%y)
		Label20.TextSize  = Label20.TextSize - ((100%x/480) + 1)
		txtWMN.SetLayout(41.66666667%x, 36.34232122%y, 20.83333333%x, 4.68933177%y)
		txtWMN.TextSize = txtWMN.TextSize - ((100%x/480) + 1)
		Label22.SetLayout(62.5%x, 36.34232122%y, 40%x, 4.68933177%y)
		Label22.TextSize = Label22.TextSize - ((100%x/480) + 1)
		Label23.SetLayout(62.5%x, 41.03165299%y, 40%x, 4.68933177%y)
		Label23.TextSize = Label23.TextSize - ((100%x/480) + 1)
		txtWMF.SetLayout(41.66666667%x, 41.03165299%y, 20.83333333%x, 4.68933177%y)
		txtWMF.TextSize = txtWMF.TextSize - ((100%x/480) + 1)
		Label24.SetLayout(33.33333333%x, 41.03165299%y, 8.333333333%x, 4.68933177%y)
		Label24.TextSize = Label24.TextSize - ((100%x/480) + 1)
		
		Label26.SetLayout(2.083333333%x, 46.8933177%y, 29.16666667%x, 4.68933177%y)
		Label26.TextSize  = Label26.TextSize - ((100%x/480) + 1)
		Label25.SetLayout(33.33333333%x, 46.8933177%y, 8.333333333%x, 4.68933177%y)
		Label25.TextSize  = Label25.TextSize - ((100%x/480) + 1)
		txtWIN.SetLayout(41.66666667%x, 46.8933177%y, 20.83333333%x, 4.68933177%y)
		txtWIN.TextSize = txtWIN.TextSize - ((100%x/480) + 1)
		Label27.SetLayout(62.5%x, 46.8933177%y, 40%x, 4.68933177%y)
		Label27.TextSize = Label27.TextSize - ((100%x/480) + 1)
		Label28.SetLayout(62.5%x, 51.58264947%y, 40%x, 4.68933177%y)
		Label28.TextSize = Label28.TextSize - ((100%x/480) + 1)
		txtWIF.SetLayout(41.66666667%x, 51.58264947%y, 20.83333333%x, 4.68933177%y)
		txtWIF.TextSize = txtWIF.TextSize - ((100%x/480) + 1)
		Label29.SetLayout(33.33333333%x, 51.58264947%y, 8.333333333%x, 4.68933177%y)
		Label29.TextSize = Label29.TextSize - ((100%x/480) + 1)
		
		'Panel2.SetLayout(0, 60.96131301%y, 100%x, 28.13599062%y)
		Panel2.SetLayout(0, 60.96131301%y, 100%x, 26%y)
		Label7.SetLayout(0, 0, 100%x, 4.68933177%y)
		Label7.TextSize = Label7.TextSize - ((100%x/480) + 1)
		
		Label8.SetLayout(2.083333333%x, 4.68933177%y, 33.33333333%x, 4.68933177%y)
		Label8.TextSize = Label8.TextSize - ((100%x/480) + 1)
		txtWSS.SetLayout(41.66666667%x, 4.68933177%y, 20.83333333%x, 4.68933177%y)
		txtWSS.TextSize = txtWSS.TextSize - ((100%x/480) + 1)
		Label31.SetLayout(62.5%x, 4.68933177%y, 40%x, 4.68933177%y)
		Label31.TextSize = Label31.TextSize - ((100%x/480) + 1)
		
		Label34.SetLayout(2.083333333%x, 9.37866354%y, 33.33333333%x, 4.68933177%y)
		Label34.TextSize = Label34.TextSize - ((100%x/480) + 1)
		txtWDS.SetLayout(41.66666667%x, 9.37866354%y, 20.83333333%x, 4.68933177%y)
		txtWDS.TextSize = txtWDS.TextSize - ((100%x/480) + 1)
		Label32.SetLayout(62.5%x, 9.37866354%y, 40%x, 4.68933177%y)
		Label32.TextSize = Label32.TextSize - ((100%x/480) + 1)
		
		Label39.SetLayout(2.083333333%x, 14.06799531%y, 33.33333333%x, 4.68933177%y)
		Label39.TextSize = Label39.TextSize - ((100%x/480) + 1)
		txtWAS.SetLayout(41.66666667%x, 14.06799531%y, 20.83333333%x, 4.68933177%y)
		txtWAS.TextSize = txtWAS.TextSize - ((100%x/480) + 1)
		Label36.SetLayout(62.5%x, 14.06799531%y, 40%x, 4.68933177%y)
		Label36.TextSize = Label36.TextSize - ((100%x/480) + 1)
		
		Label30.SetLayout(2.083333333%x, 18.75732708%y, 33.33333333%x, 4.68933177%y)
		Label30.TextSize = Label30.TextSize - ((100%x/480) + 1)
		txtWMS.SetLayout(41.66666667%x, 18.75732708%y, 20.83333333%x, 4.68933177%y)
		txtWMS.TextSize = txtWMS.TextSize - ((100%x/480) + 1)
		Label37.SetLayout(62.5%x, 18.75732708%y, 40%x, 4.68933177%y)
		Label37.TextSize = Label37.TextSize - ((100%x/480) + 1)
		
		Label33.SetLayout(2.083333333%x, 23.44665885%y, 33.33333333%x, 4.68933177%y)
		Label33.TextSize = Label33.TextSize - ((100%x/480) + 1)
		txtWIS.SetLayout(41.66666667%x, 23.44665885%y, 20.83333333%x, 4.68933177%y)
		txtWIS.TextSize = txtWIS.TextSize - ((100%x/480) + 1)
		Label41.SetLayout(62.5%x, 23.44665885%y, 40%x, 4.68933177%y)
		Label41.TextSize = Label41.TextSize - ((100%x/480) + 1)
		
		'Panel3.SetLayout(0, 89.09730363%y, 100%x, 6.682297773%y)
		Panel3.SetLayout(0, 85%y, 100%x, 6.682297773%y)
		rbO.SetLayout(4.166666667%x, 0, 29.16666667%x, 3.516998828%y)
		rbO.TextSize = rbO.TextSize - ((100%x/480) + 1)
		rbM.SetLayout(4.166666667%x, 3.165298945%y, 29.16666667%x, 3.516998828%y)
		rbM.TextSize = rbM.TextSize - ((100%x/480) + 1)
		Panel4.SetLayout(33.33333333%x, 0, 66.66666667%x, 7.033997655%y)
		cbOA.SetLayout(4.166666667%x, 1.172332943%y, 29.16666667%x, 4.68933177%y)
		cbOA.TextSize = cbOA.TextSize - ((100%x/480) + 1)
		cbPM.SetLayout(33.33333333%x, 1.172332943%y, 29.16666667%x, 4.68933177%y)
		cbPM.TextSize = cbPM.TextSize - ((100%x/480) + 1)
	
		'btnKembali.SetLayout(0.416666667%x, 95.8968347%y, 33.33333333%x, 4.103165299%y)
		btnKembali.SetLayout(0.416666667%x, 93%y, 33.33333333%x, 5.5%y)
		btnKembali.TextSize = btnKembali.TextSize - ((100%x/480) + 1)
		'btnKP.SetLayout(62.08333333%x, 95.8968347%y, 37.5%x, 4.103165299%y)
		btnKP.SetLayout(62.08333333%x, 93%y, 37.5%x, 5.5%y)
		btnKP.TextSize = btnKP.TextSize - ((100%x/480) + 1)
		
	Catch
		ToastMessageShow(LastException, False)
	End Try
	
	
End Sub
Sub rbO_CheckedChange(Checked As Boolean)
	Try
		Panel2.Enabled = True
		Panel2.Visible = True
		Panel4.Enabled = False
		Panel4.Visible = False
		Panel6.Enabled = True
		Panel6.Visible = True
	Catch
		Log(LastException)
	End Try
End Sub

Sub rbM_CheckedChange(Checked As Boolean)
	Try
		Panel2.Enabled = False
		Panel2.Visible = False
		Panel4.Enabled = True
		Panel4.Visible = True
		Panel6.Enabled = False
		Panel6.Visible = False
		
		cbOA.Checked = False
		cbPM.Checked = False
		cbPM.Enabled = False
	Catch
		Log(LastException)
	End Try
End Sub

Sub cbPM_CheckedChange(Checked As Boolean)
	
End Sub

Sub cbOA_CheckedChange(Checked As Boolean)
	If cbOA.Checked = True Then
		cbPM.Enabled = True
	Else
		cbPM.Checked = False
		cbPM.Enabled = False
	End If
End Sub

Sub btnKP_Click
	Try
		'ToastMessageShow("btnKP clicked", False)
		
		If rbO.Checked = True Then
			'ToastMessageShow("rbO.Checked.", False)
			Dim wsn As Int = txtWSN.Text
			Dim wsf As Int = txtWSF.Text
			Dim wdn As Int = txtWDN.Text
			Dim wdf	As Int = txtWDF.Text
			Dim wan As Int = txtWAN.Text
			Dim waf	As Int = txtWAF.Text
			Dim wmn	As Int = txtWMN.Text
			Dim wmf As Int = txtWMF.Text
			Dim win As Int = txtWIN.Text
			Dim wif As Int = txtWIF.Text
		
			Dim wss As Int = txtWSS.Text
			Dim wds As Int = txtWDS.Text
			Dim was As Int = txtWAS.Text
			Dim wms As Int = txtWMS.Text
			'Dim wis As Int = txtWIS.Text
			
			If wsn > 1 And wsn < 121 Then
				If wsf > 4 And wsf < 91 Then
					If wdn > 1 And wdn < 121 Then
						If wdf > 4 And wdf < 91 Then
							If wan > 1 And wan < 61 Then
								If waf > 4 And waf < 61 Then
									If wmn > 1 And wmn < 61 Then
										If wmf > 4 And wmf < 46 Then
											If win > 1 And win < 11 Then
												If wif > 4 And wif < 181 Then
													If wss > 4 And wss < 31 Then
														If wds > 4 And wds < 31 Then
															If was > 4 And was < 31 Then
																If wms > 4 And wms < 31 Then
																	sendCmd("kontrol ampli murottal")
																	Wait(40)
																	sendCmd(txtWSN.Text & "/" & txtWSF.Text & "/" & txtWDN.Text & "/" & txtWDF.Text & "/" & txtWAN.Text & "/" & txtWAF.Text & "/" & txtWMN.Text & "/" & txtWMF.Text & "/" & txtWIN.Text & "/" & txtWIF.Text & "/" & txtWSS.Text & "/" & txtWDS.Text & "/" & txtWAS.Text & "/" & txtWMS.Text & "/") '& txtWIS.Text)
																	Wait(40)
																Else
																	ToastMessageShow("Masukkan nilai menit stop murottal maghrib 5-30", False)
																End If
															Else
																ToastMessageShow("Masukkan nilai menit stop murottal ashar 5-30", False)
															End If
														Else
															ToastMessageShow("Masukkan nilai menit stop murottal dhuhur 5-30", False)
														End If
													Else
														ToastMessageShow("Masukkan nilai menit stop murottal shubuh 5-30", False)
													End If
												Else
													ToastMessageShow("Masukkan nilai off ampli isya' 5-180 menit", False)
												End If
											Else
												ToastMessageShow("Masukkan nilai on ampli isya' 2-10 menit", False)
											End If
										Else
											ToastMessageShow("Masukkan nilai off ampli maghrib 5-45 menit", False)
										End If
									Else
										ToastMessageShow("Masukkan nilai on ampli mahgrib 2-60 menit", False)
									End If
								Else
									ToastMessageShow("Masukkan nilai off ampli ashar 5-60 menit", False)
								End If
							Else
								ToastMessageShow("Masukkan nilai on ampli ashar 2-60 menit", False)
							End If
						Else
							ToastMessageShow("Masukkan nilai off ampli dhuhur 5-90 menit", False)
						End If
					Else
						ToastMessageShow("Masukkan nilai on ampli dhuhur 2-120 menit", False)
					End If
				Else
					ToastMessageShow("Masukkan nilai off ampli shubuh 5-90 menit", False)
				End If
			Else
				ToastMessageShow("Masukkan nilai on ampli shubuh 2-120 menit", False)		
			End If
		Else If rbM.Checked = True Then
			'ToastMessageShow("rbM.Checked.", False)
			If cbOA.Checked = True And cbPM.Checked = False Then
				sendCmd("on ampli manual")
				Wait(40)
				sendCmd("stop murottal manual")
				Wait(40)
			Else If cbOA.Checked = True And cbPM.Checked = True Then
				sendCmd("on ampli manual")
				Wait(40)
				sendCmd("play murottal manual")
				Wait(40)
			Else If cbOA.Checked = False And cbPM.Checked = False Then
				sendCmd("stop murottal manual")
				Wait(40)
				sendCmd("off ampli manual")
				Wait(40)
			End If
		End If
	Catch
		ToastMessageShow("btnKP error: " & LastException, False)
	End Try
End Sub

Sub btnKembali_Click
	Try
		StartActivity(Main)
		Activity.Finish
	Catch
		'Log(LastException)
		ToastMessageShow(LastException, False)
	End Try
	
End Sub

Sub sendCmd (strCmd As String)
	Try
		'ToastMessageShow("ShrIP = " & Main.ShrIP & " | " & "ShrPort = " & Main.ShrPort, False)
		Main.UdpP.Initialize(strCmd.GetBytes("ASCII"), Main.ShrIP, Main.ShrPort)
		Main.UdpS.Send(Main.UdpP)
	Catch
		ToastMessageShow("sendCmd Error: " & LastException, False)
	End Try
End Sub

Sub Wait(ms As Int)
	Try
		Dim n As Long = DateTime.Now + ms
		Do While DateTime.Now < n
		Loop
	Catch
		ToastMessageShow(LastException, False)
	End Try
End Sub

Sub btnVolume_Click
	
End Sub


Circuit Diagram Auto Murottal (ESP8266 + DF Player Mini MP3 + RTC DS3231 + Relay Module + Low Pass Filter + PAM 8403)

Source: https://youtu.be/JJ2kHLaI-4w








1 komentar: