-
Notifications
You must be signed in to change notification settings - Fork 0
/
mantra_prayer.ino
139 lines (123 loc) · 3.03 KB
/
mantra_prayer.ino
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
/*
* kodingan ini dibuat dan dikembangkan dari penggabungan dan penambahan fungsi tmbahan baru dari penulis
* Project Name : PROJECT PENGINGAT SEMBAHYANG OTOMATIS
* Develop by : IDNmakerspace Algorithm Factory
* Last Edited : Jum'at, 29 Januari 2021
*/
#include <DS1307RTC.h>
#include <RTClib.h>
#include <Wire.h>
#include <Time.h>
#include <TimeLib.h>
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
SoftwareSerial dfplayer(10, 11);
RTC_DS1307 rtc;
int RelayPin = 7;
int LedPin = 13;
char namaHari[7][12] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"};
void setup()
{
Serial.begin(9600);
dfplayer.begin(9600);
rtc.begin();
pinMode(RelayPin, OUTPUT);
pinMode(LedPin, OUTPUT);
digitalWrite(LedPin,HIGH); //kondisi lampu indikator hidup
delay(1000);
digitalWrite(RelayPin, HIGH); //on
delay(1000);
digitalWrite(RelayPin, LOW); //off
delay(1000);
//set DFplayer
mp3_set_serial(dfplayer);
delay(10);
mp3_set_volume(100);
delay(10);
mp3_play (1);
delay(10);
}
void loop()
{
DateTime now = rtc.now();
Serial.print(namaHari[now.dayOfTheWeek()]);
Serial.print(',');
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
if (now.hour() == 6 && now.minute() == 0) // untuk sembahyang pagi
{
digitalWrite(RelayPin, HIGH);
Serial.print("Hidup...");
mp3_play ();
delay(10);
}
else if (now.hour() == 6 && now.minute() == 7)
{
digitalWrite(RelayPin, LOW);
Serial.print("Mati...");
}
delay(1000);
//untuk sembahyang siang
if (now.hour() == 12 && now.minute() == 0) //untuk sembahyang siang
{
digitalWrite(RelayPin, HIGH);
Serial.print("Hidup...");
mp3_play ();
delay(10);
}
else if (now.hour() == 12 && now.minute() == 7)
{
digitalWrite(RelayPin,LOW);
Serial.print("Mati...");
}
delay(1000);
//untuk sembahyang malam
if (now.hour() == 18 && now.minute() == 0) //untuk sembahyang malam
{
digitalWrite(RelayPin, HIGH);
Serial.print("Hidup...");
mp3_play ();
delay(10);
}
else if (now.hour() == 18 && now.minute() == 7)
{
digitalWrite(RelayPin,LOW);
Serial.print("Mati...");
}
delay(1000);
}
void time(int number)
{
if (number >= 0 && number < 10)
{
Serial.write('0');
}
Serial.print(number);
}
void kalibrasi()
{
DateTime now = rtc.now();
now.day() = 21; //atur tanggal
now.month() = 8; //atur bulan
now.year() = 2; //atur tahun
now.hour() = 7; //atur jam
now.minute() = 55; //atur menit
now.second() = 1; //atur detik
rtc.write(now);
Serial.print("Waktu telah di atur ke: ");
rtc.printTo(Serial);
Serial.println();
Serial.print("Program berakhir (RESET untuk menjalakan lagi)");
while(1);
}