const byte subuh = 1, zuhur = 2, ashar = 3, maghrib = 4, isya = 5;
byte hoursPray, minutesPray, newHours, newMinutes;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
doubleToHrMin(subuh, hoursPray, minutesPray);
Serial.print("Data hoursPray: ");
Serial.println(hoursPray);
Serial.print("Data minutesPray: ");
Serial.println(minutesPray);
tambahWaktu(hoursPray, minutesPray, 1, newHours, newMinutes);
Serial.print("Add New hoursPray: ");
Serial.println(newHours);
Serial.print("Add New minutesPray: ");
Serial.println(newMinutes);
kurangWaktu(hoursPray, minutesPray, 1, newHours, newMinutes);
Serial.print("sub New hoursPray: ");
Serial.println(newHours);
Serial.print("sub New minutesPray: ");
Serial.println(newMinutes);
}
void loop() {
// put your main code here, to run repeatedly:
}
void doubleToHrMin(byte sNum, byte &InHoursPray, byte &InMinutesPray) {
InHoursPray = sNum + 2;
InMinutesPray = sNum + 4;
}
// Fungsi untuk menambah waktu
void tambahWaktu(byte inHours, byte inMinute, byte adder, byte &hoursPray, byte &minutesPray) {
minutesPray = inMinute + adder;
if (minutesPray > 59) {
hoursPray = inHours + 1;
minutesPray -= 60;
} else {
hoursPray = inHours;
}
}
// Fungsi untuk mengurangi waktu
void kurangWaktu(byte inHours, byte inMinute, byte substract, byte &hoursPray, byte &minutesPray) {
minutesPray = inMinute - substract;
if (minutesPray < 0) {
hoursPray = inHours - 1;
minutesPray += 60;
} else {
hoursPray = inHours;
}
}