//RITHIN V// Define the pins for PIR sensors
const int pirSensor1Pin = A5; // PIR sensor 1 pin
const int pirSensor2Pin = A4; // PIR sensor 2 pin
// Define the number of LEDs and the first LED pin
const int numLeds = 10; // Number of LEDs
const int firstLedPin = 4; // First LED pin
// Define the duration to keep all LEDs lit (in milliseconds)
const unsigned long ledDuration = 15000; // 15 seconds
// Define the delay between lighting up each LED (in milliseconds)
const int ledDelay = 1000; // Adjust this for your desired LED animation speed
void setup() {
// Initialize PIR sensor pins as inputs
pinMode(pirSensor1Pin, INPUT);
pinMode(pirSensor2Pin, INPUT);
// Initialize LED pins as outputs
for (int i = firstLedPin; i < firstLedPin + numLeds; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, LOW); // Turn off all LEDs initially
}
}
void loop() {
// Check if motion is detected at PIR sensor 1
if (digitalRead(pirSensor1Pin) == HIGH) {
// Motion detected at PIR sensor 1, light up LEDs from bottom to top
for (int i = firstLedPin; i < firstLedPin + numLeds; i++) {
digitalWrite(i, HIGH);
delay(ledDelay); // Adjust the delay for your desired LED animation speed
}
delay(ledDuration); // Keep all LEDs lit for 30 seconds
// Turn off all LEDs after the duration
for (int i = firstLedPin; i < firstLedPin + numLeds; i++) {
digitalWrite(i, LOW);
}
}
// Check if motion is detected at PIR sensor 2
if (digitalRead(pirSensor2Pin) == HIGH) {
// Motion detected at PIR sensor 2, light up LEDs from top to bottom
for (int i = firstLedPin + numLeds - 1; i >= firstLedPin; i--) {
digitalWrite(i, HIGH);
delay(ledDelay); // Adjust the delay for your desired LED animation speed
}
delay(ledDuration); // Keep all LEDs lit for 30 seconds
// Turn off all LEDs after the duration
for (int i = firstLedPin; i < firstLedPin + numLeds; i++) {
digitalWrite(i, LOW);
}
}
}