#include <WiFi.h>
#include <WebServer.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
// === WiFi Ayarları ===
const char* ssid = "SSID_ADI";
const char* password = "WIFI_SIFRE";
// === LCD Ayarları ===
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_ROWS 4
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_ROWS);
// === Keypad Ayarları ===
const byte ROWS = 5;
const byte COLS = 6;
byte rowPins[ROWS] = {23,19,18,17,16};
byte colPins[COLS] = {32,33,25,26,27,4};
char keys[ROWS][COLS] = {
{'J', '+','1', '2', '3', 'A' },
{'K', '-','4', '5', '6', 'B' },
{'L', '/','7', '8', '9', 'C' },
{'Z', '=','.', '0', 'M', 'D' },
{'V', 'W','Q', 'S', 'E', 'R' }
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
// === HTTP Server ===
WebServer server(80);
// === Liste ===
const int MAX_ROWS = 50;
String dataList[MAX_ROWS];
int totalRows = 0;
int currentIndex = 0;
// === Satır Gösterme ===
void showRows() {
lcd.clear();
for (int i = 0; i < 4; i++) {
int idx = currentIndex + i;
if (idx < totalRows) {
lcd.setCursor(2, i);
lcd.print(dataList[idx]);
Serial.printf("Satir %d: %s\n", idx+1, dataList[idx].c_str());
}
}
}
// === Satır Silme ===
void deleteRow(int btnIndex) {
int idx = currentIndex + btnIndex;
if (idx < totalRows) {
Serial.printf("Buton %d basildi, silinen: %s\n", btnIndex+1, dataList[idx].c_str());
// satırı sil
for (int i = idx; i < totalRows - 1; i++) {
dataList[i] = dataList[i + 1];
}
totalRows--;
// currentIndex ayarı
if (currentIndex > totalRows - 4) currentIndex = max(0, totalRows - 4);
showRows();
}
}
// === HTTP POST Liste Alma ===
void handlePostData() {
if (server.hasArg("plain")) {
String body = server.arg("plain");
totalRows = 0;
int start = 0;
while (start < body.length() && totalRows < MAX_ROWS) {
int end = body.indexOf('\n', start);
if (end == -1) end = body.length();
dataList[totalRows] = body.substring(start, end);
dataList[totalRows].trim(); // boşluk/CR temizle
totalRows++;
start = end + 1;
}
server.send(200, "text/plain", "Liste alindi. Satir sayisi: " + String(totalRows));
Serial.printf("Liste alindi! Toplam %d satir yuklendi.\n", totalRows);
showRows();
} else {
server.send(400, "text/plain", "Gecersiz veri");
}
}
// === Setup ===
void setup() {
Serial.begin(115200);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.print("WiFi Baglaniyor");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi baglandi. IP: " + WiFi.localIP().toString());
lcd.clear();
lcd.print("IP: ");
lcd.print(WiFi.localIP());
Serial.print(WiFi.localIP());
// HTTP endpoint
server.on("/liste", HTTP_POST, handlePostData);
server.begin();
Serial.println("HTTP Server basladi.");
}
// === Loop ===
void loop() {
server.handleClient();
char key = keypad.getKey();
if (key) {
if (key == '1') deleteRow(0);
if (key == '2') deleteRow(1);
if (key == '3') deleteRow(2);
if (key == '4') deleteRow(3);
}
}
23
19
18
17
D6