#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Address may vary, check with your specific LCD
const int pirPins[] = {2, 3, 4, 5, 6}; // Array of PIR sensor pins
const int ledPins[] = {7, 8, 9, 10, 11}; // Array of LED pins
void setup() {
Serial.begin(9600);
lcd.begin(16, 2); // Initialize LCD
lcd.backlight(); // Turn on the backlight
lcd.print("Motion: ");
for (int i = 0; i < 5; i++) {
pinMode(pirPins[i], INPUT);
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
for (int i = 0; i < 5; i++) {
int motion = digitalRead(pirPins[i]);
if (motion == HIGH) {
Serial.print("Motion detected by Sensor ");
Serial.println(i + 1);
lcd.setCursor(8, 0); // Set cursor to show sensor number
lcd.print(i + 1); // Display sensor number on LCD
// Turn on the corresponding LED solid
digitalWrite(ledPins[i], HIGH);
// Flicker the other LEDs continuously
for (int j = 0; j < 5; j++) {
if (j != i) {
flickerLED(ledPins[j]);
}
}
}
}
}
void flickerLED(int pin) {
// Flicker the LED by turning it on and off quickly
digitalWrite(pin, HIGH);
delay(50);
digitalWrite(pin, LOW);
delay(50);
}