#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// I2C address 0x27 ba 0x3F hoy
LiquidCrystal_I2C lcd(0x27, 16, 2);
// IR sensor er pin gulo define korlam
const int s1Pin = 2;
const int s2Pin = 3;
const int s3Pin = 4;
const int s4Pin = 5;
void setup() {
lcd.init();
lcd.backlight();
pinMode(s1Pin, INPUT);
pinMode(s2Pin, INPUT);
pinMode(s3Pin, INPUT);
pinMode(s4Pin, INPUT);
lcd.setCursor(0, 0);
lcd.print("Library Seats");
delay(2000);
lcd.clear();
}
void loop() {
int s1 = digitalRead(s1Pin);
int s2 = digitalRead(s2Pin);
int s3 = digitalRead(s3Pin);
int s4 = digitalRead(s4Pin);
int freeCount = 0;
// C-style char array use kora hoyeche String er bodole
char status1[5];
char status2[5];
char status3[5];
char status4[5];
if (s1 == LOW) {
strcpy(status1, "O");
} else {
strcpy(status1, "F");
freeCount++;
}
if (s2 == LOW) {
strcpy(status2, "O");
} else {
strcpy(status2, "F");
freeCount++;
}
if (s3 == LOW) {
strcpy(status3, "O");
} else {
strcpy(status3, "F");
freeCount++;
}
if (s4 == LOW) {
strcpy(status4, "O");
} else {
strcpy(status4, "F");
freeCount++;
}
// LCD Row 1: S1 & S2 status display korbe
lcd.setCursor(0, 0);
lcd.print("S1:");
lcd.print(status1);
lcd.print(" S2:");
lcd.print(status2);
lcd.print(" S3:");
lcd.print(status3);
// LCD Row 2: S3 status & total free seat count dekhabe
lcd.setCursor(0, 1);
lcd.print("S4:");
lcd.print(status4);
lcd.print(" TotalFree=");
lcd.print(freeCount);
delay(1000); // Prot 1 second por por update hobe
}