Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Multi-Sensor Safety System with Servo Control and LCD Feedback

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Multi-Sensor Safety System with Servo Control and LCD Feedback

Circuit Documentation

Summary

The circuit is designed to monitor environmental conditions and detect events such as fire, gas leaks, water levels, and motion. It utilizes an Arduino UNO as the central microcontroller to process inputs from various sensors and actuates a servo and buzzer based on specific conditions. The circuit includes a flame sensor, gas sensor, water level sensor, PIR motion sensor, an I2C LCD screen for display, a buzzer for audible alerts, and a servo motor for physical responses.

Component List

KY-026 Flame Sensor

MQ-4 Gas Sensor

Water Level Sensor

Arduino UNO

PIR Motion Sensor (Wokwi Compatible)

I2C LCD 16x2 Screen

Buzzer

Servo

Wiring Details

KY-026 Flame Sensor

MQ-4 Gas Sensor

Water Level Sensor

PIR Motion Sensor (Wokwi Compatible)

I2C LCD 16x2 Screen

Buzzer

Servo

Documented Code

#include <Servo.h>
#include <LiquidCrystal_I2C.h>

#define FIRE_SENSOR_PIN A0
#define GAS_SENSOR_PIN A1
#define PIR_SENSOR_PIN 2
#define WATER_LEVEL_PIN A2
#define BUZZER_PIN 10
#define SERVO_PIN 9

Servo myServo;
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
    pinMode(FIRE_SENSOR_PIN, INPUT);
    pinMode(GAS_SENSOR_PIN, INPUT);
    pinMode(PIR_SENSOR_PIN, INPUT);
    pinMode(WATER_LEVEL_PIN, INPUT);
    pinMode(BUZZER_PIN, OUTPUT);

    lcd.begin();
    lcd.backlight();

    myServo.attach(SERVO_PIN);
    myServo.write(0);  // Initial position

    Serial.begin(9600);
}

void loop() {
    int fireValue = analogRead(FIRE_SENSOR_PIN);
    int gasValue = analogRead(GAS_SENSOR_PIN);
    int pirValue = digitalRead(PIR_SENSOR_PIN);
    int waterLevel = analogRead(WATER_LEVEL_PIN);

    lcd.clear();

    // Fire Detection
    if (fireValue > 400) { // Adjust threshold as needed
        lcd.setCursor(0, 0);
        lcd.print("Fire Alert!");
        digitalWrite(BUZZER_PIN, HIGH);
        myServo.write(90); // Servo action, e.g., close door
    } else {
        digitalWrite(BUZZER_PIN, LOW);
        myServo.write(0);  // Default position
    }

    // Gas Detection
    if (gasValue > 300) { // Adjust threshold as needed
        lcd.setCursor(0, 1);
        lcd.print("Gas Leak!");
        digitalWrite(BUZZER_PIN, HIGH);
    }

    // Motion Detection
    if (pirValue == HIGH) {
        lcd.setCursor(0, 0);
        lcd.print("Intruder Detected");
        digitalWrite(BUZZER_PIN, HIGH);
    }

    // Water Level Detection
    if (waterLevel < 200) { // Adjust threshold for water level
        lcd.setCursor(0, 1);
        lcd.print("Flood Risk!");
        digitalWrite(BUZZER_PIN, HIGH);
    }

    delay(1000);  // Adjust delay as per requirements
}

This code is designed to run on the Arduino UNO microcontroller. It initializes the sensors and the LCD screen in the setup() function and continuously monitors the sensors in the loop() function. When a sensor detects a condition above a predefined threshold, it triggers an alert on the LCD screen and activates the buzzer. The servo motor is also actuated in case of fire detection.