Open nextecsolutions opened 10 months ago
Wa-Alykom-Essalam Bilal. what you could do it with modula operator "%" . Something like this: if (hour>12) { hour = hour%12; }
or:
hour= (hour>12?hour%12:hour)
try it and tell me if it works Ahmed
Another solution , is to use this lib: https://github.com/PaulStoffregen/Time which is already needed for the PrayerTimes library to work. you could use these functions: hourFormat12(); // the hour now in 12 hour format isAM(); // returns true if time now is AM isPM(); // returns true if time now is PM
Asalam-U-Aliakum Brother, I tired both methods but it didn't work for me, By the way what do you mean by (modula operator) I didn't understand it properly. Regards, Bilal
modula operator is X%Y which is the remainder of dividing X/Y . please tell me what have you tried, and what was the output. please share some code , so I can help you.
Ahmed
Thanks for the reply brother. Though i tried but i couldn't succeed, The source code is not mine i only made some changes to it suit my needs, I have attached the source code file please have look.
///Source Code////
char weekDay[7][12] = {"MONDAY, " , "TUESDAY, ", "WEDENSDAY, ", "THURSDAY, ", "JUMAH, ", "SATURDAY, ", "SUNDAY, ", }; // array hari, dihitung mulai dari senin, hari senin angka nya =0, int Buz = A0; // 4 default int langkah; int lama_tampilnya; boolean Menu_Setting = false;
///////////////////////////////// Defining Button Pins ////////////////////////////////////////
////////////////////this code is for RTC settings according to the laptop//// ///// //year, month, date, hour, min, sec and week-day(starts from 0 and goes to 6) //writing any non-existent time-data may interfere with normal operation of the RTC. //Take care of week-days too. //DateTime dt(2017, 5, 4, 15, 11, 0, 4);
/*
DMD dmd(1, 1); //to set the number of panels you use
double times[sizeof(TimeName) / sizeof(char*)]; int ihti = 30; // Correction of Time Minutes Prayer Schedule void ScanDMD() { dmd.scanDisplayBySPI(); }
void setup() {
char val; //pencacah nilai Serial.begin(9600); //setting baurate serial
pinMode(Buz, OUTPUT);//----pin 2 for the Maghrib call to prayer alarm ---connect with the buzzer pinMode(3, OUTPUT);//----pin e ralay TF S-W
langkah = 0; rtc.begin(); //rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above (This is for setting the clock) Wire.begin(); Timer1.initialize( 500 ); Timer1.attachInterrupt( ScanDMD ); dmd.clearScreen( true );
pinMode(tombol_bOK, INPUT_PULLUP); // Pin Mode as Input with Internal Pull Up pinMode(Jam_bUP, INPUT_PULLUP); // Mode Pin Sebagai Input dengan Pull Up Internal pinMode(Jam_bDN, INPUT_PULLUP); // Mode Pin Sebagai Input dengan Pull Up Internal
attachInterrupt(0, Setting, FALLING); } ////////////////////////////////// Looping/Repeat function /////////////////////////////////////// void loop() {
dmd.setKecerahan(115); if (Menu_Setting ) {
MenuSetting(); // If the OK/Interrupt button is pressed, you will enter the Manual settings menu
} mulai(); }
/////////////////////////////////// Interrupt Button Setting //////////////////////////////////////// void Setting() { Menu_Setting = true; // Activate the Settings Menu }
////////////////////////////////////// Setting Menu Function////////// void MenuSetting() { char val; //value counter val = Serial.read(); Serial.print(val);
DateTime now = rtc.now(); String Teks; int tgl = now.date(); //Tanggal//Date int bln = now.month(); //Bulan // Month int thn = now.year(); //Tahun//Year int hours, minutes; //prayer schedule hours and minutes int jame = now.hour(); //Clock int menit_e = now.minute(); //minute /////////////////////////----------/////////////////
int harin_e = harin_e; //hari // day detachInterrupt(0);// Turn off interrupt "0" delay(500);
///////////////////////////////////////Hour & Minute Settings ///////
int kasus = 0; setTimes: val = Serial.read();
// Setting Times (Hours & Minutes) if (digitalRead(Jam_bUP) == LOW || val == 'H') { // Minute Setting Button delay(10); menit_e++; // Delay Button & Add Minute Value Serial.print(val); if (menit_e >= 60) { menit_e = 0; //Minute Value Limit Over 59 Returns to 0 } while (digitalRead(Jam_bUP) == LOW) {} // Lock the Minute Setting Button Until Release the Button } if (digitalRead(Jam_bDN) == LOW || val == 'G') { // Minute setting button delay(10); jame++; Serial.print(val); // Delay Button & Increase Clock Value if (jame >= 24) { jame = 0; // Hour Value Limit Over 23 Returns to 0 } while (digitalRead(Jam_bDN) == LOW) {} // Lock the clock setting button until the button is released } if (val == 'B') { val = 'B'; kasus = 1; } if (val == 'C') { val = 'C'; kasus = 2; } if (val == 'D') { val = 'D'; kasus = 3; } if (val == 'E') { val = 'E'; kasus = 4; } if (val == 'X') { val = 'X'; kasus = 7; }
setTgl: val = 'W' ; val = Serial.read();
// Setting tanggal if (digitalRead(Jam_bUP) == LOW || val == 'I') { // Date setting button delay(10); tgl++; Serial.print(val); if (tgl >= 32) { tgl = 1; // Batas Nilai tgl Lebih dari 31 Kembali ke 1 } while (digitalRead(Jam_bUP) == LOW) {} // Kunci Tombol Setting tgl Sampai Lepas Tombol } if (digitalRead(Jam_bDN) == LOW || val == 'J') { // Month Setting delay(10); bln++; // Delay Tombol & Tambah Nilai bln if (bln >= 13) { bln = 1; // Month Value Limit More than 12 Return to 1 } while (digitalRead(Jam_bDN) == LOW) {} // Lock the month setting button until release the button } if (val == 'B') { val = 'B'; kasus = 1; } if (val == 'C') { val = 'C'; kasus = 2; } if (val == 'D') { val = 'D'; kasus = 3; } if (val == 'E') { val = 'E'; kasus = 4; } if (val == 'X') { val = 'X'; kasus = 7; }
// ///////=======setting thn==
setThn: val = 'W' ; val = Serial.read();
// Setting thn if (digitalRead(Jam_bUP) == LOW || val == 'K') { // Setting year delay(10); thn++; // Delay Tombol & Tambah Nilai thn Serial.print(val); if (thn >= 9999) { thn = 0; // Batas Nilai Menit Lebih dari 9999 Kembali ke 0 } while (digitalRead(Jam_bUP) == LOW) {} // Kunci Tombol Setting thn Sampai Lepas Tombol } if (digitalRead(Jam_bDN) == LOW || val == 'L') { // Tombol Setting thn delay(10); thn--; // Delay Tombol & Tambah Nilai thn if (thn <= 0) { thn = 0; // Limit Value less than 0 Return to 0 } while (digitalRead(Jam_bDN) == LOW) {} // Lock the yr Setting Button Until Release the Button } if (val == 'B') { val = 'B'; kasus = 1; } if (val == 'C') { val = 'C'; kasus = 2; } if (val == 'D') { val = 'D'; kasus = 3; } if (val == 'E') { val = 'E'; kasus = 4; } if (val == 'X') { val = 'X'; kasus = 7; }
// ======Day settings======= //day count starts from 0,1,2,3,4,5,6 = Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
setHari: val = 'W' ; val = Serial.read();
// Setting Times hari if (digitalRead(Jam_bUP) == LOW || val == 'M') { // Day setting button harin_e = harin_e; delay(10); harin_e++; // Delay Button & Add Value by day, if (harin_e >= 7) { harin_e = 0; // Minute Value Limit Over 6 Returns to 0 } while (digitalRead(Jam_bUP) == LOW) {} // Lock the Day Setting Button Until Release the Button } if (digitalRead(Jam_bDN) == LOW || val == 'N') { //Day setting button harin_e = harin_e; delay(10); harin_e--; // Delay Button & Add Day Value if (harin_e <= 0) { harin_e = 0; // Batas Nilai kurang dari 0 Kembali ke 0 } while (digitalRead(Jam_bDN) == LOW) {} // Kunci Tombol Setting hari Sampai Lepas Tombol } if (val == 'B') { val = 'B'; kasus = 1; } if (val == 'C') { val = 'C'; kasus = 2; } if (val == 'D') { val = 'D'; kasus = 3; } if (val == 'E') { val = 'E'; kasus = 4; } if (val == 'X') { val = 'X'; kasus = 7; }
///============OK button======================= val = Serial.read(); Serial.print(val); if ((digitalRead(tombol_bOK) == LOW ) || (val == 'A')) { // Finish Setting button
val = Serial.read();
Serial.print("--tombol oke ditekan-- ");
kasus = kasus + 1;
dmd.clearScreen(true); // Remove P10 Display
DateTime dt(thn, bln, tgl, jame, menit_e, 0, harin_e);
// DateTime dt(2017, 5, 4, 15, 11, 0, 4);
rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above
while (digitalRead(tombol_bOK) == LOW ) {}
delay(100);
// ============================================case-case===================
} if (kasus == 1 || val == 'B') { //kasus seting jam
dmd.clearScreen(true);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "set-J", 5, 0);
String xjam = Konversi(jame) + ":" + Konversi(menit_e) ;
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
delay (100);
goto setTimes; //run to the clock setting function
} if (kasus == 2 || val == 'C') { //date setting case
dmd.clearScreen(true);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "Dte", 3, 0);
String xjam = Konversi(tgl) + "/" + Konversi(bln) ;
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
delay (100);
goto setTgl;//lari ke fungsi setting tanggal
} if (kasus == 3 || val == 'D') { ///kasus seting tahun
dmd.clearScreen(true);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "'Yr", 3, 0);
String xjam = Konversi(thn) ;
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
delay (100);
goto setThn; //lari ke fungsi setting tahun
}
if (kasus == 4 || val == 'E') { //kasus seting hari
dmd.clearScreen(true);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "Day", 4, 0);
String xjam = Konversi(harin_e) ;
if (harin_e == 0) {
xjam = "MON";
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
} if (harin_e == 1) {
xjam = "TUE";
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
}
if (harin_e == 2) {
xjam = "WED";
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
} if (harin_e == 3) {
xjam = "THU";
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
} if (harin_e == 4) {
xjam = "JUM";
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
} if (harin_e == 5) {
xjam = "SAT";
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
} if (harin_e == 6) {
xjam = "SUN";
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
}
delay (100);
goto setHari; //lari ke seting hari
}
if (kasus == 5 ) { // case completed dmd.clearScreen(true); goto endSetting; delay(500);
} if (kasus == 7) { //bluetooth exit dmd.clearScreen(true); // Remove P10 Display DateTime dt(thn, bln, tgl, jame, menit_e, 0, harin_e); // DateTime dt(2017, 5, 4, 15, 11, 0, 4); rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above delay(100); dmd.clearScreen(true); goto endSetting; delay(500);
}
endSetting: // Label End Setting attachInterrupt(0, Setting, FALLING); // Interrupt Tombol OK Menu_Setting = false;
kasus = 0;
}
//////////////////////==========================Program Jam==============
int menite = 1; //long period of iqomah void mulai() { char val; //value counter val = Serial.read(); val = Serial.read(); Serial.print(val);
dmd.clearScreen( true ); long mulai = millis();
/// rtc.begin(); DateTime now = rtc.now(); String Teks; int tgl = now.date(); //DATE int bln = now.month(); //MONTH int thn = now.year(); //YEAR int hours, minutes; //prayer schedule hours and minutes int jame = now.hour(); //hour int menit_e = now.minute(); //minute int harin_e = harin_e; //day
/// if (digitalRead(tombol_bOK) == LOW || val == 'A') { val = 'A';
MenuSetting(); //If the OK/Interrupt button is pressed, you will enter the Manual settings menu
delay(1000);
} if (now.second() > 1) { ///////////////menu button interrupt-----------
digitalWrite(3, LOW);// turn on relay
/////////////////////
///Asr prayer call to prayer coding
get_float_time_parts(times[3], hours, minutes);
if (now.hour() == hours && now.minute() == minutes && now.second() > 1 ) {
digitalWrite(2, HIGH);//alarm pray
delay(1000);
digitalWrite(2, LOW);//alarm pray
delay(500);
digitalWrite(2, HIGH);//alarm pray/salat
delay(1000);
digitalWrite(2, LOW);//alarm pray/salat
delay(500);
int lamanya;
for (lamanya = 0; lamanya < 150; lamanya++) {
lamanya = lamanya + 1;
delay(1000);
///ASAR
dmd.selectFont(SystemFont5x7);
dmd.clearScreen( true );
Teks = "AZAN "; // show on top row
char pj = Teks.length() + 1;
char tampil[pj];
Teks.toCharArray(tampil, pj);
dmd.drawString(0, 0, tampil, pj, 0); // show coordinates
String iqomahx = "ASR" ;
int panjang_iqomahx = iqomahx.length() + 1;
char waktu_iqomahx[panjang_iqomahx];
iqomahx.toCharArray(waktu_iqomahx, panjang_iqomahx);
dmd.drawString(0, 9, waktu_iqomahx, panjang_iqomahx, 0);
delay(1000);
dmd.clearScreen( true );
}
//iqamah/jamaat----------------------------------
int langkah;
int waktu_iqomah;
int panjang_iqomah;
int iqomah;
dmd.clearScreen( true );
dmd.clearScreen( true );
dmd.drawString(0, 0, "SALAT", 5, 0); //show coordinates
int tampil;
int detik = 60, menit = 10;
for (detik = 60; detik >= 0; detik--) {
delay(1000);
String iqomah = Konversi(menit) + ":" + Konversi(detik);
int panjang_iqomah = iqomah.length() + 1;
char waktu_iqomah[panjang_iqomah];
iqomah.toCharArray(waktu_iqomah, panjang_iqomah);
dmd.drawString(0, 9, waktu_iqomah, panjang_iqomah, 0);
if (detik <= 0) {
detik = 60;
menit = menit - 1;
}
/////buzer sholat////
if (menit <= 0 && detik == 7) {
digitalWrite(2, HIGH);//alarm PRAY/SALAT
} if (menit <= 0 && detik == 6) {
digitalWrite(2, LOW);//alarm pray/salat
} if (menit <= 0 && detik == 5) {
digitalWrite(2, HIGH);//alarm pra/salat
} if (menit <= 0 && detik == 4) {
digitalWrite(2, LOW);//alarm pray/salat
} if (menit <= 0 && detik == 3) {
digitalWrite(2, HIGH);//alarm pray/salat
} if (menit <= 0 && detik == 2) {
digitalWrite(2, LOW);//alarm pray/salat
}
///////////////
if (menit <= 0 && detik <= 1) {
dmd.clearScreen( true );
for (tampil = 0; tampil < 500 ; tampil++) {
menit = 0;
detik = 0;
dmd.drawString(0, 0, "SALAT", 5, 0); //show coordinates
digitalWrite(3, HIGH);//turn off relay power TF-SW
///////////////////////
now = rtc.now();
String xjam = Konversi(now.hour()) + ":" + Konversi(now.minute()) ; //tampilan jam
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
/////////////////////
///////////////////////
delay (1000);
}
}
}
///////////////
}
///Maghrib prayer call to prayer coding
get_float_time_parts(times[4], hours, minutes);
if (now.hour() == hours && now.minute() == minutes && now.second() > 1 ) {
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
int lamanya;
for (lamanya = 0; lamanya < 150; lamanya++) {
lamanya = lamanya + 1;
delay(1000);
///MAGHRIB
dmd.selectFont(SystemFont5x7);
dmd.clearScreen( true );
Teks = "AZAN "; //baris atas
char pj = Teks.length() + 1;
char tampil[pj];
Teks.toCharArray(tampil, pj);
dmd.drawString(0, 0, tampil, pj, 0); //koordinat tampilan
String iqomahx = "MGHRB" ;
int panjang_iqomahx = iqomahx.length() + 1;
char waktu_iqomahx[panjang_iqomahx];
iqomahx.toCharArray(waktu_iqomahx, panjang_iqomahx);
dmd.drawString(0, 9, waktu_iqomahx, panjang_iqomahx, 0);
delay(1000);
dmd.clearScreen( true );
}
//iqomah----------------------------------
int langkah;
int waktu_iqomah;
int panjang_iqomah;
int iqomah;
dmd.clearScreen( true );
dmd.clearScreen( true );
dmd.drawString(0, 0, "SALAT", 5, 0); //koordinat tampilan
int tampil;
int detik = 60, menit = 10;
for (detik = 60; detik >= 0; detik--) {
delay(1000);
String iqomah = Konversi(menit) + ":" + Konversi(detik);
int panjang_iqomah = iqomah.length() + 1;
char waktu_iqomah[panjang_iqomah];
iqomah.toCharArray(waktu_iqomah, panjang_iqomah);
dmd.drawString(0, 9, waktu_iqomah, panjang_iqomah, 0);
if (detik <= 0) {
detik = 60;
menit = menit - 1;
}
/////buzer SALAT////
if (menit <= 0 && detik == 7) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 6) {
digitalWrite(2, LOW);//alarm sholat
} if (menit <= 0 && detik == 5) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 4) {
digitalWrite(2, LOW);//alarm sholat
} if (menit <= 0 && detik == 3) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 2) {
digitalWrite(2, LOW);//alarm sholat
}
///////////////
if (menit <= 0 && detik <= 1) {
dmd.clearScreen( true );
for (tampil = 0; tampil < 500 ; tampil++) {
menit = 0;
detik = 0;
dmd.drawString(0, 0, "SALAT", 5, 0); //koordinat tampilan
digitalWrite(3, HIGH);//matikan relay power TF-SW
///////////////////////
now = rtc.now();
String xjam = Konversi(now.hour()) + ":" + Konversi(now.minute()) ; //tampilan jam
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
/////////////////////
///////////////////////
delay (1000);
}
}
}
///////////////
}
///Isha salat coding
get_float_time_parts(times[6], hours, minutes);
if (now.hour() == hours && now.minute() == minutes && now.second() > 1) {
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
int lamanya;
for (lamanya = 0; lamanya < 150; lamanya++) {
lamanya = lamanya + 1;
delay(1000);
///ISHA
dmd.selectFont(SystemFont5x7);
dmd.clearScreen( true );
Teks = "AZAN "; //baris atas
char pj = Teks.length() + 1;
char tampil[pj];
Teks.toCharArray(tampil, pj);
dmd.drawString(0, 0, tampil, pj, 0); //koordinat tampilan
String iqomahx = "ISHA" ;
int panjang_iqomahx = iqomahx.length() + 1;
char waktu_iqomahx[panjang_iqomahx];
iqomahx.toCharArray(waktu_iqomahx, panjang_iqomahx);
dmd.drawString(0, 9, waktu_iqomahx, panjang_iqomahx, 0);
delay(1000);
dmd.clearScreen( true );
}
//iqomah----------------------------------
int langkah;
int waktu_iqomah;
int panjang_iqomah;
int iqomah;
dmd.clearScreen( true );
dmd.clearScreen( true );
dmd.drawString(0, 0, "SALAT", 5, 0); //koordinat tampilan
int tampil;
int detik = 60, menit = 10;
for (detik = 60; detik >= 0; detik--) {
delay(1000);
String iqomah = Konversi(menit) + ":" + Konversi(detik);
int panjang_iqomah = iqomah.length() + 1;
char waktu_iqomah[panjang_iqomah];
iqomah.toCharArray(waktu_iqomah, panjang_iqomah);
dmd.drawString(0, 9, waktu_iqomah, panjang_iqomah, 0);
if (detik <= 0) {
detik = 60;
menit = menit - 1;
}
/////buzer sholat////
if (menit <= 0 && detik == 7) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 6) {
digitalWrite(2, LOW);//alarm sholat
} if (menit <= 0 && detik == 5) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 4) {
digitalWrite(2, LOW);//alarm sholat
} if (menit <= 0 && detik == 3) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 2) {
digitalWrite(2, LOW);//alarm sholat
}
///////////////
if (menit <= 0 && detik <= 1) {
dmd.clearScreen( true );
for (tampil = 0; tampil < 500 ; tampil++) {
menit = 0;
detik = 0;
dmd.drawString(0, 0, "SALAT", 5, 0); //koordinat tampilan
digitalWrite(3, HIGH);//matikan relay power TF-SW
///////////////////////
now = rtc.now();
String xjam = Konversi(now.hour()) + ":" + Konversi(now.minute()) ; //tampilan jam
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
/////////////////////
///////////////////////
delay (1000);
}
}
}
///////////////
}
///Jumah salaat coding/////
int harin_e = now.dayOfWeek();
get_float_time_parts(times[2], hours, minutes);
if ((now.hour() == hours && now.minute() == minutes && harin_e == 4 && now.second() > 1 ))
{
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
int lamanya;
for (lamanya = 0; lamanya < 2700; lamanya++) {
lamanya = lamanya + 1;
delay(1000);
dmd.drawString(0, 0, "Jumat", 5, 0); //koordinat tampilan
digitalWrite(3, HIGH);//matikan relay power TF-SW
///////////////////////
now = rtc.now();
String xjam = Konversi(now.hour()) + ":" + Konversi(now.minute()) ; //tampilan jam
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
}
}
///coding azan DZUHUR
get_float_time_parts(times[2], hours, minutes);
if ((now.hour() == hours && now.minute() == minutes && harin_e != 4 && now.second() > 1 ))
{
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
int lamanya;
for (lamanya = 0; lamanya < 150; lamanya++) {
lamanya = lamanya + 1;
delay(1000);
///DZUHUR
dmd.selectFont(SystemFont5x7);
dmd.clearScreen( true );
Teks = "AZAN "; //baris atas
char pj = Teks.length() + 1;
char tampil[pj];
Teks.toCharArray(tampil, pj);
dmd.drawString(0, 0, tampil, pj, 0); //koordinat tampilan
String iqomahx = "ZUHR" ;
int panjang_iqomahx = iqomahx.length() + 1;
char waktu_iqomahx[panjang_iqomahx];
iqomahx.toCharArray(waktu_iqomahx, panjang_iqomahx);
dmd.drawString(0, 9, waktu_iqomahx, panjang_iqomahx, 0);
delay(1000);
dmd.clearScreen( true );
}
//iqomah----------------------------------
int langkah;
int waktu_iqomah;
int panjang_iqomah;
int iqomah;
dmd.clearScreen( true );
dmd.clearScreen( true );
dmd.drawString(0, 0, "IQAMH", 5, 0); //koordinat tampilan
int tampil;
int detik = 60, menit = 10;
for (detik = 60; detik >= 0; detik--) {
delay(1000);
String iqomah = Konversi(menit) + ":" + Konversi(detik);
int panjang_iqomah = iqomah.length() + 1;
char waktu_iqomah[panjang_iqomah];
iqomah.toCharArray(waktu_iqomah, panjang_iqomah);
dmd.drawString(0, 9, waktu_iqomah, panjang_iqomah, 0);
if (detik <= 0) {
detik = 60;
menit = menit - 1;
}
/////buzer sholat////
if (menit <= 0 && detik == 7) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 6) {
digitalWrite(2, LOW);//alarm sholat
} if (menit <= 0 && detik == 5) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 4) {
digitalWrite(2, LOW);//alarm sholat
} if (menit <= 0 && detik == 3) {
digitalWrite(2, HIGH);//alarm sholat
} if (menit <= 0 && detik == 2) {
digitalWrite(2, LOW);//alarm sholat
}
///////////////
if (menit <= 0 && detik <= 1) {
dmd.clearScreen( true );
for (tampil = 0; tampil < 500 ; tampil++) {
menit = 0;
detik = 0;
dmd.drawString(0, 0, "SALAT", 5, 0); //koordinat tampilan
digitalWrite(3, HIGH);//matikan relay power TF-SW
///////////////////////
now = rtc.now();
String xjam = Konversi(now.hour()) + ":" + Konversi(now.minute()) ; //tampilan jam
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
/////////////////////
///////////////////////
delay (1000);
}
}
}
///////////////
}
///coding azan FAJR
get_float_time_parts(times[0], hours, minutes);
if (now.hour() == hours && now.minute() == minutes && now.second() > 1 ) {
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
digitalWrite(2, HIGH);//alarm sholat
delay(1000);
digitalWrite(2, LOW);//alarm sholat
delay(500);
int lamanya;
for (lamanya = 0; lamanya < 150; lamanya++) {
lamanya = lamanya + 1;
delay(1000);
///FAJAR
dmd.selectFont(SystemFont5x7);
dmd.clearScreen( true );
Teks = "AZAN "; //baris atas
char pj = Teks.length() + 1;
char tampil[pj];
Teks.toCharArray(tampil, pj);
dmd.drawString(0, 0, tampil, pj, 0); //koordinat tampilan
String iqomahx = "FAJR" ;
int panjang_iqomahx = iqomahx.length() + 1;
char waktu_iqomahx[panjang_iqomahx];
iqomahx.toCharArray(waktu_iqomahx, panjang_iqomahx);
dmd.drawString(0, 9, waktu_iqomahx, panjang_iqomahx, 0);
delay(1000);
dmd.clearScreen( true );
}
//iqomah/Jamaat----------------------------------
int langkah;
int waktu_iqomah;
int panjang_iqomah;
int iqomah;
dmd.clearScreen( true );
dmd.clearScreen( true );
dmd.drawString(0, 0, "IQAMH", 5, 0); //koordinat tampilan
int tampil;
int detik = 60, menit = 10;
for (detik = 60; detik >= 0; detik--) {
delay(1000);
String iqomah = Konversi(menit) + ":" + Konversi(detik);
int panjang_iqomah = iqomah.length() + 1;
char waktu_iqomah[panjang_iqomah];
iqomah.toCharArray(waktu_iqomah, panjang_iqomah);
dmd.drawString(0, 9, waktu_iqomah, panjang_iqomah, 0);
if (detik <= 0) {
detik = 60;
menit = menit - 1;
}
/////buzer sholat////
if (menit <= 0 && detik == 7) {
digitalWrite(Buz, HIGH);//alarm sholat
} if (menit <= 0 && detik == 6) {
digitalWrite(Buz, LOW);//alarm sholat
} if (menit <= 0 && detik == 5) {
digitalWrite(Buz, HIGH);//alarm sholat
} if (menit <= 0 && detik == 4) {
digitalWrite(Buz, LOW);//alarm sholat
} if (menit <= 0 && detik == 3) {
digitalWrite(Buz, HIGH);//alarm sholat
} if (menit <= 0 && detik == 2) {
digitalWrite(Buz, LOW);//alarm sholat
}
///////////////
if (menit <= 0 && detik <= 1) {
dmd.clearScreen( true );
for (tampil = 0; tampil < 500 ; tampil++) {
menit = 0;
detik = 0;
dmd.drawString(0, 0, "SALAT", 5, 0); //koordinat tampilan
digitalWrite(3, HIGH);//matikan relay power TF-SW
///////////////////////
now = rtc.now();
String xjam = Konversi(now.hour()) + ":" + Konversi(now.minute()) ; //tampilan jam
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 9, sjam, pjg, 0);
/////////////////////
///////////////////////
delay (1000);
}
}
}
}
///////////////
DateTime now = rtc.now();
if (now.second() > 10) {
String Teks;
///===============Coordinate setting-uses Android GPS to determine your position==================
double lintang = 34.083672; //Latitude
double bujur = 74.797279; //Longitude
int Z = 5; //Time Zone GMT WIB usually 7
int tgl = now.date(); //Tanggal
int bln = now.month(); //Bulan
int thn = now.year(); //Tahun
int hours1, minutes1, hours2, minutes2, hours3, minutes3, hours4, minutes4, hours5, minutes5, hours6, minutes6, hours7, minutes7; //prayer hours and prayer minutes
long mulai = millis();
set_calc_method(Karachi); //The calculation method follows ISNA
set_asr_method(Hanafi); //Opinion of Imam Shafi'i
set_high_lats_adjust_method(AngleBased);
set_fajr_angle(18); //Adjust fajr angle
set_isha_angle(18); ////Adjust isha angle
get_prayer_times(thn, bln, tgl, lintang, bujur, Z, times);
///////////////interupsi tombol menu-----------
char val; //value counter
if (digitalRead(tombol_bOK) == LOW || val == 'A') {
val = 'A';
MenuSetting(); // Jika Tombol OK/Interrupt ditekan maka masuk menu setting Manual
}
/////////////////////
///CLOCK-BIG///
dmd.clearScreen( true );
dmd.selectFont(angka6x13);
int menit_e = now.minute();
int jame = now.hour();
int detik_e = now.second();
String xjam = Konversi(jame) ; //tampilan jam
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(1, 0, sjam, pjg, 0);
/////menit///
String xxjam = Konversi(menit_e) ; //tampilan menit
int xpjg = xxjam.length() + 1;
char xsjam[xpjg];
xxjam.toCharArray(xsjam, xpjg);
dmd.drawString(18, 0, xsjam, xpjg, 0);
///titik dua :
///
String hariku1 = weekDay[now.dayOfWeek()] ;
int dowo1 = hariku1.length() + 1;
char detikanku1[dowo1];
hariku1.toCharArray(detikanku1, dowo1);
dmd.drawString(35, 0, detikanku1, dowo1, 0);
////
dmd.selectFont(SystemFont5x7);
dmd.drawChar( 14, 4, ':', GRAPHICS_NOR ); // clock colon overlay on
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_OR ); // clock colon overlay off
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_NOR ); // clock colon overlay on
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_OR ); // clock colon overlay off
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_NOR ); // clock colon overlay on
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_OR ); // clock colon overlay off
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_NOR ); // clock colon overlay on
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_OR ); // clock colon overlay off
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_NOR ); // clock colon overlay on
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_OR ); // clock colon overlay off
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_NOR ); // clock colon overlay on
delay( 1000 );
dmd.drawChar( 14, 4, ':', GRAPHICS_OR ); // clock colon overlay off
delay( 1000 );
///////////////interupsi tombol menu-----------
if (digitalRead(tombol_bOK) == LOW || val == 'A') {
val = 'A';
MenuSetting(); // Jika Tombol OK/Interrupt ditekan maka masuk menu setting Manual
}
///////////////interupsi tombol menu-----------
if (digitalRead(tombol_bOK) == LOW || val == 'A') {
val = 'A';
MenuSetting(); // Jika Tombol OK/Interrupt ditekan maka masuk menu setting Manual
}
/////////////////////
}
////running text clock above----//
dmd.clearScreen( true );
String Teks;
int tgl = now.date(); //Tanggal
int bln = now.month(); //Bulan
int thn = now.year(); //Tahun
int hours0, minutes0, hours1, minutes1, hours2, minutes2, hours3, minutes3, hours4, minutes4, hours5, minutes5, hours6, minutes6, hours7, minutes7; //jam sholat dan menit sholat
int jame = now.hour(); //hour
int menit_e = now.minute(); //menit
int detik_e = now.second(); //detik
delay(100);
detachInterrupt(0);// Turn off interrupt "0"
//// //Show day running text
} if (now.second() > 30) {
///
///BIG CLOCK///
dmd.clearScreen( true );
int menit_e = now.minute();
int jame = now.hour();
int detik_e = now.second();
String xjam = Konversi(jame) ; //tampilan jam
int pjg = xjam.length() + 1;
char sjam[pjg];
xjam.toCharArray(sjam, pjg);
dmd.drawString(0, 0, sjam, pjg, 0);
/////menit///
String xxjam = Konversi(menit_e) ; //tampilan menit
int xpjg = xxjam.length() + 1;
char xsjam[xpjg];
xxjam.toCharArray(xsjam, xpjg);
dmd.drawString(20, 0, xsjam, xpjg, 0);
///titik dua
String xxxjam = ":" ; //colon display
int xxpjg = xxxjam.length() + 1;
char xxsjam[xxpjg];
xxxjam.toCharArray(xxsjam, xxpjg);
dmd.drawString(14, 0, xxsjam, xxpjg, 0);
///////////////interupsi tombol menu-----------
char val; //value counter
if (digitalRead(tombol_bOK) == LOW || val == 'A') {
val = 'A';
MenuSetting(); //If the OK/Interrupt button is pressed, you will enter the Manual settings menu
}
int hours0, minutes0, hours1, minutes1, hours2, minutes2, hours3, minutes3, hours4, minutes4, hours5, minutes5, hours6, minutes6, hours7, minutes7; //jam sholat dan menit sholat
get_float_time_parts(times[0], hours0, minutes0);
if ((minutes0 >= 1) && (minutes0 < 10)) {
minutes0 = 50 + minutes0;
hours0--;
}
if (minutes0 == 00) {
minutes0 = 50;
hours0--;
}
else {
minutes0 = minutes0 - 10 ;
}
get_float_time_parts(times[0], hours1, minutes1);//fajr
get_float_time_parts(times[2], hours2, minutes2);//dzuhur
get_float_time_parts(times[3], hours3, minutes3);//asar
get_float_time_parts(times[4], hours4, minutes4);//maghrib
get_float_time_parts(times[5], hours5, minutes5);//what is this?
get_float_time_parts(times[6], hours6, minutes6);//isha
Teks = weekDay[now.dayOfWeek()] + Konversi(now.date()) + "-" + Konversi(now.month()) + "-" + Konversi(now.year()) + " NAMAZ KE AWQAAT : "+" IMSAK:" + Konversi(hours0) + ":" + Konversi(minutes0) + " FAJR:" + Konversi(hours1) + ":" + Konversi(minutes1)
+ " ZUHUR:" + Konversi(hours2) + ":" + Konversi(minutes2) + " ASAR:" + Konversi(hours3) + ":" + Konversi(minutes3)
+ " MAGHRIB:" + Konversi(hours4) + ":" + Konversi(minutes4) + " ISHA:" + Konversi(hours6) + ":" + Konversi(minutes6) ;
int kecepatan;
kecepatan = 70; //speed of running text
int pj = Teks.length() + 1;
char tampil[pj];
Teks.toCharArray(tampil, pj);
dmd.selectFont(SystemFont5x7);
dmd.drawMarquee(tampil, pj, 32, 9);
///////////////interupsi tombol menu-----------
val; //pencacah nilai
if (digitalRead(tombol_bOK) == LOW || val == 'A') {
val = 'A';
MenuSetting(); // If the OK/Interrupt button is pressed, you will enter the Manual settings menu
}
/////////////////////
long timer = millis();
boolean ret = false;
while (!ret) {
if ((timer + kecepatan) < millis()) {
ret = dmd.stepSplitMarquee(8, 15, 0); ///animated rows 8 through 15, up to column 0
timer = millis();
///TOMBOL SET JAM//
if (digitalRead(tombol_bOK) == LOW) {
MenuSetting(); //If the OK/Interrupt button is pressed, you will enter the Manual settings menu
}
}
}
} }
//---------------------------------------------------------------------- ///Convert the number to have a zero in front if it is below 10
String Konversi(int sInput) { if (sInput < 10) { return"0" + String(sInput); } else { return String(sInput); } }
sorry for not answering you so far. I am trying to find the time to check you code. I hope sometime in the next week or so, I will answer you.
Asalamualaikum, No issues brother I will wait.
Regards Bilal
On Tue, 13 Feb 2024, 1:40 pm asmaklad, @.***> wrote:
sorry for not answering you so far. I am trying to find the time to check you code. I hope sometime in the next week or so, I will answer you.
— Reply to this email directly, view it on GitHub https://github.com/asmaklad/Arduino-Prayer-Times/issues/5#issuecomment-1940682363, or unsubscribe https://github.com/notifications/unsubscribe-auth/BC7IUY4ISVZ3H5DK55TPBALYTMNXFAVCNFSM6AAAAABB6Y7XTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBQGY4DEMZWGM . You are receiving this because you authored the thread.Message ID: @.***>
Asalam-U-Aliakum Brother, I am struggling to get the prayer times in 12hr format, Can you please provide the instructions how to edit your code to get the prayer times in 12hr Format,Thanks.
Regards, Bilal