</>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266HTTPClient.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <SoftwareSerial.h>
LiquidCrystal_I2C lcd(0x27,16,2); // Arduino İçin Adres:0x27
const char* ssid = "Beleşwifi"; //WIFI BILGILERI
const char* password = "1122335"; //WIFI SIFRESİ
// LOCALDEKİ BİLGİSAYARIN IPV4 IP ADRESİ
const char *host = "http://ipadresim/projekilit";
int sure = 1000;
const byte SatirSayisi = 4; // 4 satırlı
const byte SutunSayisi = 3; // 3 sütunlu
char tuslar[SatirSayisi][SutunSayisi] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte SatirPinleri[SatirSayisi] = {8, 7, 6, 5}; //Satırların bağlanacağı pinler
byte SutunPinleri[SutunSayisi] = {4, 3, 2}; //Sütunların bağlanacağı pinler
Keypad TusTakimi = Keypad( makeKeymap(tuslar), SatirPinleri, SutunPinleri, SatirSayisi, SutunSayisi );
String Sifre = "XXXX";
String Username = "";
String KayitId = "";
String KeypadSifre = "";
int YesilLed= 9;
int KirmiziLed= 12;
void setup() {
delay(500);
delay(500);
Serial.begin(115200);
delay(500);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(250);
}
Serial.println("");
Serial.print("Successfully connected to : ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.println();
}
HTTPClient http;
WiFiClient client1;
lcd.begin();
delay(500);
pinMode(YesilLed,OUTPUT);
pinMode(KirmiziLed,OUTPUT);
digitalWrite(YesilLed,0);
digitalWrite(KirmiziLed,0);
Serial.begin(9600);
delay(500);
yeniSerialPort.begin(9600);
delay(500);
Serial.println("Arduino Başlatıldı.");
void loop() {
String Link, Data, GercekVeri;
Data = String("veri");
Serial.println("---------------- test.php -----------------");
String planlanan = "/test.php";
Link = host + planlanan;
http.begin(client1, Link.c_str());
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
int cevap = http.POST(Data);
String veri = http.getString();
Serial.println("Gelen Cevap:" + String(cevap));
Serial.println("Gelen Veri:" + String(veri));
delay(1000);
http.end();
Serial.println("---------------- test.php -----------------");
delay(sure);
Serial.println("---------------- PlanlananKontrol.php -----------------");
planlanan = "/PlanlananKontrol.php";
Link = host + planlanan;
http.begin(client1, Link.c_str());
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
cevap = http.POST(Data);
veri = http.getString();
Serial.println("Gelen Cevap:" + String(cevap));
Serial.println("Gelen Veri:" + String(veri));
delay(1000);
http.end();
Serial.println("---------------- PlanlananKontrol.php -----------------");
delay(sure);
Serial.println("---------------- AktifKontrol.php -----------------");
String aktif = "/AktifKontrol.php";
Link = host + aktif;
http.begin(client1, Link.c_str());
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
cevap = http.POST(Data);
veri = http.getString();
Serial.println("Gelen Cevap:" + String(cevap));
Serial.println("Gelen Veri:" + String(veri));
delay(1000);
http.end();
Serial.println("---------------- AktifKontrol.php -----------------");
delay(sure);
Serial.println("---------------- NodemcuVeri.php -----------------");
String nodemcu = "/NodemcuVeri.php";
Link = host + nodemcu;
http.begin(client1, Link.c_str());
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
cevap = http.POST(Data);
veri = http.getString();
Serial.println("Gelen Cevap:" + String(cevap));
Serial.println("Gelen Veri:" + String(veri));
delay(1000);
http.end();
GercekVeri = veri;
Serial.println("Gerçek Veri:" + String(GercekVeri));
Serial.println("---------------- NodemcuVeri.php -----------------");
// GercekVeri = "username:0000;34#"
String gonderilecekVeri;
if (GercekVeri.length() > 1) {
int x1 = veri.indexOf(":");
int x2 = veri.indexOf(";");
int x3 = veri.indexOf("#");
String Username = veri.substring(0, x1);
String Sifre = veri.substring(x1 + 1, x2);
String KayitId = veri.substring(x2 + 1, x3);
Serial.println("Username:" + Username);
Serial.println("Şifre:" + Sifre);
Serial.println("KayitID:" + KayitId);
gonderilecekVeri = "Y" + Username + ":" + Sifre + ";" + KayitId + "#";
//"Yusername:0000;34#"
}
else {
gonderilecekVeri = "X";
}
Serial.println("Arduinoya Gönderilen Veri:");
char tus = TusTakimi.getKey();
if(tus != NO_KEY){
if(KeypadSifre.length()<4){
KeypadSifre += tus;
Serial.println("SİFRE:"+KeypadSifre);
}
}
if(KeypadSifre.length()<4){
LCD.setCursor(0,0);
LCD.print(" SIFRE GIRINIZ! ");
LCD.setCursor(0,1);
LCD.print(" SIFRE:"+KeypadSifre+" ");
}
if(KeypadSifre.length()==4){
Serial.println("SİFRE:"+KeypadSifre);
if(KeypadSifre==Sifre){
Serial.println("SİFRE DOGRU");
Serial.println("LUTFEN BEKLEYIN.");
LCD.clear();
LCD.setCursor(0,0);
LCD.print(" SIFRE DOGRU ");
LCD.setCursor(0,1);
LCD.print("LUTFEN BEKLEYIN.");
digitalWrite(YesilLed,1);
delay(3000);
// Ahmet 5 11/2 5;
// Yunus Emre 10 3;
int bosluk = (16-Username.length())/2;
LCD.clear();
LCD.setCursor(bosluk,0);
LCD.print(Username);
Serial.println(Username);
delay(1000);
delay(4000);
digitalWrite(YesilLed,0);
KeypadSifre = "";
}
else{
Serial.println("SİFRE YANLIS");
Serial.println("LUTFEN BEKLEYIN.");
LCD.clear();
LCD.setCursor(0,0);
LCD.print(" SIFRE YANLIS! ");
LCD.setCursor(0,1);
LCD.print("LUTFEN BEKLEYIN.");
for(int i=0;i<3;i++){
digitalWrite(KirmiziLed,1);
delay(1000);
digitalWrite(KirmiziLed,0);
delay(1000);
}
KeypadSifre = "";
}
}
if (yeniSerialPort.available()) { //Veri geldiyse
String veri = gonderilecekVeri();
Serial.println("Veri Geldi:"+veri);
if(veri.length()>0){
if(veri[0]=='X'){
Sifre = "XXXX";
KayitId = "";
Username = "";
}
else if(veri[0]=='Y'){
int x1 = veri.indexOf(":");
int x2 = veri.indexOf(";");
int x3 = veri.indexOf("#");
Username = veri.substring(1, x1);
Sifre = veri.substring(x1 + 1, x2);
KayitId = veri.substring(x2 + 1, x3);
}
}
Serial.println("Username:"+Username);
Serial.println("KayitId:"+KayitId);
Serial.println("Güncel Sifre:"+Sifre);
}
Serial.println("----------------BAĞLANTI KAPATILIYOR----------------");
delay(100000);
Serial.println();
for (byte i = 10; i > 0; i--) {
delay(1000);
Serial.println("LÜTFEN " + String(i) + " SN BEKLEYİNİZ.");
}
}
'