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

Arduino UNO-Based Fire and Gas Detection Robot with Water Pump and Motor Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Fire and Gas Detection Robot with Water Pump and Motor Control

Circuit Documentation

Summary

This circuit is designed to control a robotic system using an Arduino UNO microcontroller. The system includes various sensors, actuators, and a motor driver to perform tasks such as detecting gas and flame, controlling motors and a water pump, and activating a buzzer for alerts. The Arduino UNO serves as the central controller, interfacing with all the components and executing the embedded code to manage the system's operations.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. 1 Channel 5V Relay Module

    • Description: Relay module for switching high-power devices.
    • Pins: VCC+, VCC- (GND), IN, N.O., COM, N.C.
  3. 5V Mini Water Pump

    • Description: Small water pump powered by 5V.
    • Pins: positive pin, negative pin
  4. MQ-5 Gas Sensor

    • Description: Gas sensor for detecting LPG, natural gas, and coal gas.
    • Pins: VCC, GND, Digi Out, Analog out
  5. Rocker Switch

    • Description: On/Off switch.
    • Pins: output, input
  6. Motor and Wheels

    • Description: DC motor with attached wheels.
    • Pins: vcc, GND
  7. L298N DC Motor Driver

    • Description: Dual H-Bridge motor driver.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  8. Micro Servo 9G

    • Description: Small servo motor.
    • Pins: GND, +5V, PWM
  9. Battery 12V

    • Description: 12V battery for powering the circuit.
    • Pins: +, -
  10. KY-026 Flame Sensor

    • Description: Flame sensor for detecting fire.
    • Pins: AO, GND, VCC, DO
  11. Buzzer

    • Description: Small buzzer for sound alerts.
    • Pins: GND, IN

Wiring Details

Arduino UNO

1 Channel 5V Relay Module

5V Mini Water Pump

MQ-5 Gas Sensor

Rocker Switch

Motor and Wheels

L298N DC Motor Driver

Micro Servo 9G

Battery 12V

KY-026 Flame Sensor

Buzzer

Code Documentation

#include <Servo.h>

const int flameSensorPin = 6;
const int gasSensorPin = 10;
const int relayPin = 13;
const int servoPin = 7;
const int buzzerPin = 8;
const int flameThreshold = 500;
const int gasThreshold = 400;

const int motorA1 = 2;
const int motorA2 = 3;
const int motorB1 = 5;
const int motorB2 = 4;

const int motorAspeed = 9;
const int motorBspeed = 11;

class Buzzer {
  private:
    int buzzerPin; // Motor control pins
  public:
    Buzzer(int buzzerPin) {
      this->buzzerPin = buzzerPin;
      pinMode(buzzerPin, OUTPUT);
      this->stop();
    }
    void start(){
      digitalWrite(this->buzzerPin, HIGH);
    }
    void stop(){
      digitalWrite(this->buzzerPin, LOW);
    }
};

class Observer {
  private:
    int flameSensorPin;
    int gasSensorPin;
  public:
    Observer(int flameSensorPin, int gasSensorPin){
      this->flameSensorPin = flameSensorPin;
      this->gasSensorPin = gasSensorPin;
      pinMode(flameSensorPin, INPUT);
      pinMode(gasSensorPin, INPUT);
    }
    bool is_fire() {
    return !digitalRead(this->flameSensorPin);
    }
    bool is_gas() {
      return !digitalRead(this->gasSensorPin);
    }
};

class WaterBump {
  private:
    int relayPin;
    int servoPin;
    int dir = 1;
    int servoValue = 90;
    int stepValue = 3;
  public:
    Servo waterServo;

    WaterBump(int relayPin, int servoPin) {
      this