Minggu, 23 April 2017

jadwal Shalat gaul







#include <LiquidCrystal.h>
LiquidCrystal lcd(7,8,12,11,10,9);  // RS,E,D4,D5,D6,D7

#include "Wire.h"
#define DS1307_ADDRESS 0x68
byte zero = 0x00; //workaround for issue #527
int ct1=1;
int t1,t2,t3,j,mn,d,tg,bl,th,hk,tg2;
String hari;
String b1,b2,b3,b4,baris1,baris2,baris4,baris3;
int k=1; int tm=1;
int j1,j2,m1,m2,d1,d2;
int ct2,ct3,ht;
boolean lt1= false;
boolean lt3= false;
boolean lt2= false;
boolean jshalat= true;
String bulan;

int Bulan,tgl,sh,is,dz,as,mg;
int menitisya1,menitisya2,menitshubuh1,menitshubuh2,menitzhuhur1,menitzhuhur2;
int menitashar1,menitashar2,menitmaghrib1,menitmaghrib2;
int menitisya,menitshubuh,menitzhuhur,menitashar,menitmaghrib;

int jamisya1,jamisya2,jamshubuh1,jamshubuh2,jamzhuhur1,jamzhuhur2;
int jamashar1,jamashar2,jammaghrib1,jammaghrib2;
int jamisya,jamshubuh,jamzhuhur,jamashar,jammaghrib;

String isya,shubuh,zhuhur, ashar, maghrib;

void setup() {
    Wire.begin();
    lcd.begin(20,4);
    pinMode (2,INPUT);
    pinMode (3,INPUT);
    pinMode (4,INPUT);
}

void loop() {
 delay(100);
  t1=digitalRead(2);
  t2=digitalRead(3) ;
  t3=digitalRead(4);

  if (k==1) {
  Wire.beginTransmission(DS1307_ADDRESS);
  byte zero = 0x00;
  Wire.write(zero);
  Wire.endTransmission();
  Wire.requestFrom(DS1307_ADDRESS, 7);
   d = bcdToDec(Wire.read());
  mn = bcdToDec(Wire.read());
  j = bcdToDec(Wire.read() & 0b111111); //24 hour time
  hk = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
  tg = bcdToDec(Wire.read());
  bl = bcdToDec(Wire.read());
  th = bcdToDec(Wire.read());
    j1= j/10; j2=j%10; m1=mn/10; m2=mn%10; d1=d/10; d2=d%10;
 if (t1 ==1 && lt1 == false) {
   ct1+=1; if (ct1>19) {k=2;tm=1;ct1=1; lt1= true ;} }
  else ct1=1;
  if (t3==1 && lt3== false ){k=3;tm=1; lt3= true; }
 if (t2==1 && lt2== false ){k=3;tm=2; lt3= true; }


   baris1= "Jam     = "+String (j1)+String (j2) +":"+ String (m1)+String (m2)+":"+String (d1)+String (d2) ;
if (jshalat==true){
  ct3 +=1; if (ct3 >26) {ct3=1; ht+=1; if (ht>4) ht=1;}
  if (ht==1) {baris2 = "* "+ hari+ " "+ String (tg) +"-"+ String (bl)+"-20"+ String (th)+" *" ;
               baris3 = "** Jadwal Shalat  **" ;
               baris4 = "* Daerah Karawang  *"; }
   if (ht==2) { baris2 = "** Jadwal Shalat  *" ;
                baris3 = "*  Isya    = " + isya+"  *" ;
                baris4 = "* Shubuh  = " + shubuh+" *"; }
   if (ht==3) { baris2 = "** Jadwal Shalat **" ;
                baris3 = "* Zhuhur  = "+ zhuhur+"  *" ;
                baris4 = "* Ashar   = "+ ashar+"  *" ;  }
   if (ht==4) { baris2 = "** Jadwal Shalat  **" ;
                baris3 ="* Maghrib = " + maghrib+"  *" ;
                baris4 = "* Isya    = " + isya +"  *"; }
 }
  else {
   baris1= "Jam    : "+String (j1)+String (j2) +":"+ String (m1)+String (m2)+":"+String (d1)+String (d2) ;
    baris3= "Tanggal: "+ String (tg) +" "+ bulan ;
    baris2= "Hari   : "+ hari;
    baris4= "Tahun  : 20"+ String (th);
 }}

if (k==2) {
if (tm==1){
  baris1 ="Memasuki Menu ";
   baris2 = "Pengaturan Alat ";
   baris3="Untuk Merubah Tanggal";
   baris4 ="& Jam Agar Sesuai";
   ct1 +=1;
   if (ct1 > 10) {ct1=0;  tm=2;   }
}
if (tm==2){
  baris1="Silahkan Memilih ";
  baris2 ="2. Rubah Waktu ";
   baris3 = "3. Keluar ";
   baris4="Tekan Tmbl 2 Atau 3" ;
  if (t2==1 ) {tm=3; }
 if (t3==1 ) {tm=1; k=1; }
  if (t1==0) lt1= false;
 }
if (tm==3){
  baris1 ="Memasuki Menu ";
   baris2 = "Merubah Data Jam ";
   baris3= "Rubah Jam & Menit";
   baris4="Kemudian Tanggal";
   ct1 +=1;
   if (ct1 > 10) {ct1=0;  tm=4;   }
}


if (tm==4){
  baris1  ="Jam : "+String(j) ;
  baris2 = "1 Pengaturan Menit";
  baris3="2 Untuk Tambah";
  baris4="3 Untuk Kurangi";
  if (t2==1 ) {j+=1; if(j>23) j=0;}
 if (t3==1 ) {j-=1; if(j<0) j=23;}
 if (t1==1 && lt1== false) { tm=5; lt1=true; }
 if (t1==0) lt1= false;
}
if (tm==5){
  baris1  ="Menit : "+String(mn) ;
  baris2 = "1 Pengaturan Tanggal";
  baris3="2 Untuk Tambah";
  baris4="3 Untuk Kurangi";
  if (t2==1 ) {mn+=1; if(mn>59) mn=0;}
 if (t3==1 ) {mn-=1; if(mn<0) mn=59;}
 if (t1==1 && lt1 == false) { tm=6; lt1=true; }
 if (t1==0) lt1= false;
}
if (tm==6){
  baris1 ="Memasuki Menu ";
  baris2 = "Pengaturan Tanggal";
  baris3="";
  baris4=" ";
   ct1 +=1;
   if (ct1 > 10) {ct1=0;  tm=7;   }
}
if (tm==7){
  baris1  ="Tanggal : "+ String(tg) ;
  baris2 = "1 Pengaturan Bulan";
  baris3="2 Untuk Tambah";
  baris4="3 Untuk Kurangi";
  if (t2==1 ) {tg+=1; if(tg>31) tg=1;}
 if (t3==1 ) {tg-=1; if(tg<1) tg=31;}
 if (t1==1 && lt1 == false) { tm=8; lt1=true; }
 if (t1==0) lt1= false;
}
 if (tm==8){
  baris1  = "Bulan : "+ String(bl) ;
  baris2 = "1 Pengaturan Tahun";
  baris3="2 Untuk Tambah";
  baris4="3 Untuk Kurangi";
  if (t2==1 ) {bl+=1; if(bl>12) bl=1;}
 if (t3==1 ) {bl-=1; if(bl<1) bl=12;}
 if (t1==1 && lt1 == false) { tm=9; lt1=true; }
 if (t1==0) lt1= false;
}
if (tm==9){
  baris1  = "Tahun : "+ String(th) ;
  baris2 = "1 Pengaturan Hari";
  baris3="2 Untuk Tambah";
  baris4="3 Untuk Kurangi";
  if (t2==1 ) {th+=1; if(th>99) th=1;}
 if (t3==1 ) {th-=1; if(th<1) th=99;}
 if (t1==1 && lt1 == false) { tm=10; lt1=true; }
 if (t1==0) lt1= false;
}

 if (tm==10){
  baris1  = "Hari : "+ String(hari) ;
  baris2 = "1.Menu Selanjutnya ";
  baris3="2 Untuk Tambah";
  baris4="3 Untuk Kurangi";
  if (t2==1 ) {hk +=1; if(hk>7 ) hk=0;}
 if (t3==1 ) {hk -=1; if(hk<1) hk=7;}
 if (t1==1 && lt1 == false) { tm=11; lt1=true; }
 if (t1==0) lt1= false;
}

if (tm== 11){
   baris1 ="Data dirubah...?";
   baris2= "Tekan 2 untuk Ya    ";
  baris3="Tekan 3. untuk Tidak";
  baris4="";
if (t1==0) lt1= false;
  if (t3==1 ){ tm=1;k=1;}
 if (t2==1 ) {tm=1;k=1;
   Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero); //stop Oscillator
  Wire.write(decToBcd(1));
  Wire.write(decToBcd(mn));
  Wire.write(decToBcd(j));
  Wire.write(decToBcd(hk));
  Wire.write(decToBcd(tg));
  Wire.write(decToBcd(bl));
  Wire.write(decToBcd(th));
  Wire.write(zero); //start
  Wire.endTransmission();
  delay (100);
 }}

 delay (155);
 } // END OF K2

// Cek tanggal RTC dan sesuaikan jadwal Shalat dengan tanggal
if (tg != tg2 ) { tg2=tg;
tgl=tg ; Bulan =bl;

if (Bulan ==1) {
if (tgl < 5 ) { sh = 418; dz = 1159; as =1525 ; mg = 1813 ; is = 1928 ;}
if (tgl >4 ){ sh = 420; dz = 1201; as =1527 ; mg = 1814 ; is = 1929 ;}
if (tgl>9 ){ sh = 423; dz = 1203; as =1528 ; mg = 1816 ; is = 1931 ;}
if (tgl >14 ){ sh = 426; dz = 1205; as =1529 ; mg = 1818 ; is = 1932 ;}
if (tgl >19 ){ sh = 420; dz = 1207; as =1530 ; mg = 1819 ; is = 1932 ;}
if (tgl > 24 ){ sh = 432; dz = 1208; as =1530 ; mg = 1820 ; is = 1932 ;}
if (tgl>27 ) { sh = 433; dz = 1209; as =1530 ; mg = 1820 ; is = 1933 ;}
if (tgl>30 ){ sh = 434; dz = 1209; as =1530 ; mg = 1820 ; is = 1933 ;}
}

if (Bulan ==2) {
if (tgl<5) { sh = 435; dz = 1209; as =1529 ; mg = 1820 ; is = 1932 ;}
if (tgl>4) { sh = 437; dz = 1210; as =1528 ; mg = 1820 ; is = 1931 ;}
if (tgl>9){ sh = 438; dz = 1210; as =1526 ; mg = 1820 ; is = 1930 ;}
if (tgl>14){ sh = 440; dz = 1210; as =1523 ; mg = 1819 ; is = 1929 ;}
if (tgl>19){ sh = 441; dz = 1210; as =1520 ; mg = 1817 ; is = 1927 ;}
if (tgl>24) { sh = 442; dz = 1209; as =1518 ; mg = 1816 ; is = 1925 ;}
if (tgl>27){ sh = 442; dz = 1208; as =1514 ; mg = 1815 ; is = 1924 ;}
}

if (Bulan ==3) {
if (tgl<5){ sh = 441; dz = 1208; as =1512 ; mg = 1814 ; is = 1923 ;}
if (tgl>4){ sh = 442; dz = 1207; as =1507 ; mg = 1813 ; is = 1921 ;}
if (tgl>9) { sh = 441; dz = 1206; as =1509 ; mg = 1811 ; is = 1919 ;}
if (tgl>14){ sh = 441; dz = 1204; as =1511 ; mg = 1808 ; is = 1916 ;}
if (tgl>19){ sh = 441; dz = 1203; as =1512 ; mg = 1806 ; is = 1914 ;}
if (tgl>24) { sh = 440; dz = 1201; as =1513 ; mg = 1804 ; is = 1912 ;}
if (tgl>30) { sh = 439; dz = 1159; as =1513 ; mg = 1801 ; is = 1909 ;}
}

if (Bulan ==4) {
if (tgl<5){ sh = 439; dz = 1159; as =1514 ; mg = 1800 ; is = 1908 ;}
if (tgl>4){ sh = 438; dz = 1158; as =1514 ; mg = 1759 ; is = 1907 ;}
if (tgl>9) { sh = 438; dz = 1157; as =1514 ; mg = 1756 ; is = 1905 ;}
if (tgl>14) { sh = 437; dz = 1155; as =1514 ; mg = 1754 ; is = 1903 ;}
if (tgl>19){ sh = 436; dz = 1154; as =1514 ; mg = 1753 ; is = 1902 ;}
if (tgl>24) { sh = 435; dz = 1151; as =1514 ; mg = 1751 ; is = 1900 ;}
if (tgl>30) { sh = 435; dz = 1153; as =1513 ; mg = 1750 ; is = 1900 ;}
}

if (Bulan ==5) {
if (tgl<5){ sh = 435; dz = 1153; as =1513 ; mg = 1749 ; is = 1859 ;}
if (tgl>4){ sh = 435; dz = 1152; as =1513 ; mg = 1748 ; is = 1859 ;}
if (tgl>9){ sh = 434; dz = 1152; as =1513 ; mg = 1748 ; is = 1858 ;}
if (tgl>14){ sh = 434; dz = 1152; as =1513 ; mg = 1747 ; is = 1859 ;}
if (tgl>19){ sh = 435; dz = 1152; as =1514 ; mg = 1747 ; is = 1859 ;}
if (tgl>24) { sh = 435; dz = 1153; as =1514 ; mg = 1747 ; is = 1859 ;}
if (tgl> 30) { sh = 436; dz = 1154; as =1516 ; mg = 1747 ; is = 1900 ;}
}
if (Bulan ==6) {
if (tgl<5){ sh = 436; dz = 1154; as =1515 ; mg = 1747 ; is = 1900 ;}
if (tgl>4) { sh = 436; dz = 1154; as =1516 ; mg = 1748 ; is = 1901 ;}
if (tgl>9){ sh = 436; dz = 1155; as =1517 ; mg = 1748 ; is = 1902 ;}
if (tgl>14){ sh = 438; dz = 1157; as =1518 ; mg = 1749 ; is = 1903 ;}
if (tgl>9){ sh = 439; dz = 1158; as =1519 ; mg = 1750 ; is = 1904 ;}
if (tgl>24) { sh = 441; dz = 1159; as =1520 ; mg = 1751 ; is = 1905 ;}
if (tgl>30) { sh = 442; dz = 1200; as =1521 ; mg = 1752 ; is = 1906 ;}
}

if (Bulan ==7) {
if (tgl<5 ) { sh = 442; dz = 1200; as =1521 ; mg = 1753 ; is = 1906 ;}
if (tgl>4 ){ sh = 443; dz = 1201; as =1522 ; mg = 1754 ; is = 1907 ;}
if (tgl>9){ sh = 444; dz = 1201; as =1523 ; mg = 1754 ; is = 1908 ;}
if (tgl>14) { sh = 444; dz = 1102; as =1523 ; mg = 1755 ; is = 1908 ;}
if (tgl>19){ sh = 444; dz = 1202; as =1524 ; mg = 1756 ; is = 1908 ;}
if (tgl>24) { sh = 444; dz = 1202; as =1524 ; mg = 1757 ; is = 1909 ;}
if (tgl>27){ sh = 444; dz = 1202; as =1524 ; mg = 1757 ; is = 1908 ;}
}

if (Bulan ==8) {
if (tgl<5){ sh = 444; dz = 1202; as =1523 ; mg = 1753 ; is = 1906 ;}
if (tgl>4){ sh = 444; dz = 1202; as =1523 ; mg = 1754 ; is = 1907 ;}
if (tgl>9){ sh = 443; dz = 1201; as =1522 ; mg = 1754 ; is = 1908 ;}
if (tgl>14){ sh = 442; dz = 1200; as =1520 ; mg = 1755 ; is = 1908 ;}
if (tgl>19){ sh = 441; dz = 1159; as =1519 ; mg = 1756 ; is = 1908 ;}
if (tgl>24) { sh = 439; dz = 1157; as =1517 ; mg = 1757 ; is = 1909 ;}
if (tgl>27){ sh = 437; dz = 1156; as =1515 ; mg = 1757 ; is = 1908 ;}
}

if (Bulan ==9) {
if (tgl<5) { sh = 436; dz = 1155; as =1513 ; mg = 1755 ; is = 1903 ;}
if (tgl>4){ sh = 435; dz = 1154; as =1511 ; mg = 1754 ; is = 1902 ;}
if (tgl>9){ sh = 432; dz = 1152; as =1507 ; mg = 1753 ; is = 1901 ;}
if (tgl>14){ sh = 430; dz = 1150; as =1504 ; mg = 1752 ; is = 1900 ;}
if (tgl>19){ sh = 427; dz = 1149; as =1500 ; mg = 1751 ; is = 1859 ;}
if (tgl>24) { sh = 425; dz = 1147; as =1456 ; mg = 1750 ; is = 1858 ;}
if (tgl>27) { sh = 422; dz = 1145; as =1503 ; mg = 1749 ; is = 1857 ;}
}


if (Bulan ==10) {
if (tgl<5){ sh = 421; dz = 1145; as =1451 ; mg = 1749 ; is = 1857 ;}
if (tgl>4){ sh = 419; dz = 1144; as =1447 ; mg = 1749 ; is = 1857 ;}
if (tgl>9){ sh = 419; dz = 1144; as =1445 ; mg = 1750 ; is = 1857 ;}
if (tgl>14) { sh = 414; dz = 1141; as =1446 ; mg = 1758 ; is = 1857 ;}
if (tgl>19){ sh = 412; dz = 1140; as =1449 ; mg = 1758 ; is = 1857 ;}
if (tgl>24) { sh = 410; dz = 1140; as =1451 ; mg = 1758 ; is = 1857 ;}
if (tgl>27){ sh = 409; dz = 1139; as =1453 ; mg = 1748 ; is = 1858 ;}
if (tgl>30){ sh = 409; dz = 1139; as =1453 ; mg = 1748 ; is = 1858 ;}
}


if (Bulan ==11) {
if (tgl<5) { sh = 408; dz = 1139; as =1455 ; mg = 1749 ; is = 1859 ;}
if (tgl>4) { sh = 407; dz = 1139; as =1456 ; mg = 1749 ; is = 1900 ;}
if (tgl>9){ sh = 406; dz = 1140; as =1459 ; mg = 1750 ; is = 1902 ;}
if (tgl>14){ sh = 405; dz = 1141; as =1501 ; mg = 1758 ; is = 1904 ;}
if (tgl>19){ sh = 405; dz = 1142; as =1504 ; mg = 1758 ; is = 1907 ;}
if (tgl>24){ sh = 405; dz = 1143; as =1507 ; mg = 1756 ; is = 1909 ;}
if (tgl>30){ sh = 406; dz = 1145; as =1509 ; mg = 1758 ; is = 1912 ;}
}

if (Bulan ==12) {
if (tgl<5){ sh = 406; dz = 1145; as =1510 ; mg = 1759 ; is = 1813 ;}
if (tgl>4){ sh = 407; dz = 1147; as =1512 ; mg = 1800 ; is = 1915 ;}
if (tgl>9){ sh = 409; dz = 1149; as =1515 ; mg = 1803 ; is = 1918 ;}
if (tgl>14) { sh = 411; dz = 1152; as =1518 ; mg = 1806 ; is = 1921 ;}
if (tgl>19){ sh = 413; dz = 1154; as =1521 ; mg = 1808 ; is = 1923 ;}
if (tgl>24){ sh = 415; dz = 1156; as =1523 ; mg = 1811 ; is = 1926 ;}
if (tgl>30){ sh = 418; dz = 1159; as =1525 ; mg = 1813 ; is = 1928 ;}
}

jamshubuh=sh/100; jamshubuh1=jamshubuh/10; jamshubuh2=jamshubuh%10 ;
menitshubuh =sh%100;menitshubuh1 =menitshubuh /10; menitshubuh2 =menitshubuh %10;
shubuh =  String(jamshubuh1) + String(jamshubuh2) +":" + String(menitshubuh1) + String(menitshubuh2);

jamzhuhur =dz/100; jamzhuhur1= jamzhuhur/10; jamzhuhur2=jamzhuhur%10 ;
menitzhuhur =dz%100; menitzhuhur1 =menitzhuhur /10; menitzhuhur2 =menitzhuhur %10;
zhuhur = String(jamzhuhur1) + String(jamzhuhur2) +":" + String(menitzhuhur1) + String(menitzhuhur2);

jamashar =as /100; jamashar1= jamashar/10; jamashar2=jamashar%10 ;
menitashar =as %100; menitashar1 =menitashar /10; menitashar2 =menitashar %10;
ashar = String(jamashar1) + String(jamashar2) +":" + String(menitashar1) + String(menitashar2);

jammaghrib =mg /100; jammaghrib1= jammaghrib/10; jammaghrib2=jammaghrib%10 ;
menitmaghrib =mg %100; menitmaghrib1 =menitmaghrib /10; menitmaghrib2 =menitmaghrib %10;
maghrib = String(jammaghrib1) + String(jammaghrib2) +":" + String(menitmaghrib1) + String(menitmaghrib2);

jamisya =is /100; jamisya1= jamisya/10; jamisya2=jamisya%10 ;
menitisya =is %100; menitisya1 =menitisya /10; menitisya2 =menitisya %10;
isya = String(jamisya1) + String(jamisya2) +":" + String(menitisya1) + String(menitisya2);

}

if (k==3) {
  if (tm==1){
    if (t3==0) lt3=false;
    baris1="********************";
    baris2 ="*  Rubah Tampilan  *";
   baris3 = "* Jam & Waktu Shalat";
    baris4 = "********************";
    ct1 +=1;
   if (ct1 > 10 && lt3 == false) {ct1=0;  tm=1;k=1; jshalat=true; }   }
  if (tm==2){
    if (t3==0) lt3=false;
     baris1 ="********************";
     baris2 ="*  Rubah Tampilan  *";
     baris3 ="*  Jam & Tanggal   *";
     baris4 ="********************";
    ct1 +=1;
   if (ct1 > 10 && lt3 == false) {ct1=0;  tm=1; k=1; jshalat=false; }   } }


  if(b1!= baris1 || b2!=baris2 || b3 !=baris3 || b4!=baris4) {
  b1= baris1 ; b2=baris2 ;b3= baris3 ; b4=baris4 ;
    lcd.clear() ;
  lcd.setCursor(0,0);  lcd.print(b1);
  lcd.setCursor(0,1);  lcd.print(b2);
   lcd.setCursor(0,2);  lcd.print(b3);
  lcd.setCursor(0,3);  lcd.print(b4);
 }


  if (hk==1) hari="Minggu" ;
  if (hk==2) hari="Senin" ;
  if (hk==3) hari="Selasa" ;
  if (hk==4) hari="Rabu" ;
  if (hk==5) hari="Kamis" ;
  if (hk==6) hari="Jum'at" ;
  if (hk==7) hari="Sabtu" ;
  if (bl==1) bulan="Januari";
  if (bl==2) bulan="Februari";
  if (bl==3) bulan= "Maret";
  if (bl==4) bulan= "April";
  if (bl==5) bulan= "Mei";
  if (bl==6) bulan= "Juni";
  if (bl==7) bulan= "Juli";
  if (bl==8) bulan="Agustus";
  if (bl==9) bulan= "September";
  if (bl==10) bulan= "Oktober";
  if (bl==11) bulan= "Nopember";
  if (bl==11) bulan="Desember";
 // end loop

}
byte bcdToDec(byte val)  {
// Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
}

byte decToBcd(byte val){
// Convert normal decimal numbers to binary coded decimal
  return ( (val/10*16) + (val%10) );
}

Tidak ada komentar:

Posting Komentar