Skip to content

Commit 3f33178

Browse files
Add files via upload
1 parent 5b18234 commit 3f33178

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include <DeneyapTelegram.h>
2+
#include <Deneyap_Servo.h>
3+
#include "time.h"
4+
5+
String ID = "***********"; // Kullanıcının telegram ID numarası
6+
String begin = "************************"; // Oluşturulan botun HTTP ID numarası
7+
#define Wlanssid "*****************" // Wifi Adı
8+
#define Wlanpassword "*****************" // Wifi şifresi
9+
const char* ntpServer = "pool.ntp.org";
10+
const long gmtOffset_sec = 0;
11+
const int daylightOffset_sec = 3600;
12+
char timeHour[3];
13+
char timeDay[3];
14+
char timeMinute[3];
15+
char timeYear[5];
16+
char timeMonth[3];
17+
int Month;
18+
int Hour;
19+
int timer1, timer2, Time, losttime, firsttime;
20+
int led = RGBLED;
21+
bool light = true;
22+
Servo Servo1;
23+
DeneyapTelegram telegram;
24+
void setup() {
25+
Serial.begin(115200); // Seri port haberleşme başlatıldı
26+
WiFi.begin(Wlanssid, Wlanpassword); // WiFi haberleşme başlatılması
27+
while (WiFi.status() != WL_CONNECTED) { // bağlantının while döngüsü ile kontrol edilmesi
28+
delay(250);
29+
Serial.print(".");
30+
}
31+
Serial.println("Baglandi");
32+
telegram.begin(begin); // Telegram Bot Tokeniniz
33+
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
34+
printLocalTime();
35+
telegram.send(ID, "Mama Kabı Aktif Saat: " + String(timeDay) + "/" + String(timeMonth) + "/" + String(timeYear) + " Saat: " + String(Hour) + ":" + String(timeMinute));
36+
pinMode(led, OUTPUT);
37+
Servo1.attach(D12);
38+
Servo1.write(55);
39+
}
40+
41+
void loop() {
42+
printLocalTime();
43+
44+
if (!firsttime) {
45+
firsttime = Hour; // Saat verisi kullanılarak mama vereceği saatin belirlenmesi
46+
}
47+
losttime = Hour;
48+
if ((abs(losttime - firsttime)) >= 1) {
49+
Time = abs(losttime - firsttime);
50+
if (Time == 2) { // 2 Saatte bir mama vermesi komutu süreyi değiştirebilirsiniz.
51+
if (millis() - timer1 > 500) { // Her 100 ms de led ve buzzer'in durumu değişerek ses ve ışık yayması sağlandı
52+
timer1 = millis();
53+
light = !light;
54+
digitalWrite(led, light);
55+
}
56+
}
57+
if (Time >= 12) {
58+
cateattime();
59+
}
60+
}
61+
}
62+
void cateattime() {
63+
Servo1.write(100);
64+
telegram.send(ID, "Mama verildi. Saat: " + String(timeDay) + "/" + String(timeMonth) + "/" + String(timeYear) + " Saat: " + String(Hour) + ":" + String(timeMinute));
65+
digitalWrite(led, LOW);
66+
delay(1000);
67+
Servo1.write(55);
68+
firsttime = losttime;
69+
}
70+
void printLocalTime() {
71+
struct tm timeinfo;
72+
if (!getLocalTime(&timeinfo)) {
73+
Serial.println("Failed to obtain time");
74+
return;
75+
}
76+
strftime(timeDay, 3, "%d", &timeinfo);
77+
strftime(timeMonth, 3, "%D", &timeinfo);
78+
strftime(timeYear, 5, "%Y", &timeinfo);
79+
strftime(timeHour, 3, "%H", &timeinfo);
80+
strftime(timeMinute, 3, "%M", &timeinfo);
81+
Hour = atoi(timeHour);
82+
Hour = Hour + 2;
83+
}

0 commit comments

Comments
 (0)