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

Arduino UNO-Based Fire Detection and Extinguishing Robot with Flame Sensors and Servo Motors

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Fire Detection and Extinguishing Robot with Flame Sensors and Servo Motors

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed to control a robotic vehicle equipped with flame sensors and servos. The circuit uses an Arduino UNO microcontroller to read sensor data and control motors and servos. The vehicle can operate in both manual and automatic modes, detecting and responding to fire using flame sensors.

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. Micro Servo 9G

    • Description: Small servo motor for precise control.
    • Pins: GND, +5V, PWM
  3. KY-026 Flame Sensor

    • Description: Sensor module for detecting flame.
    • Pins: A0, GND, VCC, D0
  4. Puente H Carrito

    • Description: H-bridge motor driver for controlling DC motors.
    • Pins: OUT1, OUT2, OUT3, OUT4, 12V, GND, 5V, ENA, IN1, IN2, IN3, IN4, ENB, 5VEN
  5. Motor with Reducer

    • Description: DC motor with a gear reducer.
    • Pins: 3 - 6 VCC, GND
  6. Battery 12V

    • Description: 12V battery for powering the circuit.
    • Pins: +, -
  7. V_REG_LD1117VXX

    • Description: Voltage regulator for providing stable 5V output.
    • Pins: GND, OUT, IN

Wiring Details

Arduino UNO

Micro Servo 9G

KY-026 Flame Sensor

Puente H Carrito

Motor with Reducer

Battery 12V

V_REG_LD1117VXX

Documented Code

#define ENA 10
#define IN1 9
#define IN2 8
#define IN3 7
#define IN4 6
#define ENB 5
#define SERVO_PIN 11
#define SERVO1_PIN 2       // Bottom-Right horizontal
#define SERVO2_PIN 3       // Top-Left vertical
#define SERVO3_PIN 4       // Bottom-Right vertical
#define ir_R A0
#define ir_L A2
#define ir_F A1

#include <Servo.h>

int s1, s2, s3;
Servo steeringServo;
int lastSteeringAngle = 90;

// ====== السيرفو الأول (Bottom-Right horizontal) ======
Servo servo1;
int lastServo1Angle = 90;

// ====== السيرفو الثاني (Top-Left vertical) ======
Servo servo2;
int lastServo2Angle = 90;

// ====== السيرفو الثالث (Bottom-Right vertical) ======
Servo servo3;
int lastServo3Angle = 90;

bool isAutoMode = true;

void setup() {
  // إعداد دبابيس المحرك
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENB, OUTPUT);
  
  pinMode(ir_R, INPUT);// declare fire sensor pin as input
  pinMode(ir_F, INPUT);// declare fire sensor pin as input
  pinMode(ir_L, INPUT);// declare fire sensor pin as input  
  
  // إعداد السيرفو
  steeringServo.attach(SERVO_PIN);
  servo1.attach(SERVO1_PIN);
  servo2.attach(SERVO2_PIN);
  servo3.attach(SERVO3_PIN);
  
  steeringServo.write(90);     // وضع البداية
  servo1.write(90);
  servo2.write(90);
  servo3.write(90);
  
  Serial.begin(9600);
}

void handleMotorCommands(char command) {
  switch(command) {
    case 'F':  // سرعة 85 للأمام
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
      analogWrite(ENA, 85);
      analogWrite(ENB, 85);
      break;
      
    case 'B':  // سرعة 150 للأمام
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
      analogWrite(ENA, 150);
      analogWrite(ENB, 150);
      break;
      
    case 'C':  // سرعة 255 للأمام
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
      analogWrite(ENA, 0);
      analogWrite(ENB, 255);
      break;
      
    case 'D':  // سرعة 85 للخلف
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
      analogWrite(ENA, 85);
      analogWrite(ENB, 85);
      break;
      
    case 'E':  // سرعة 150 للخلف
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
      analogWrite(ENA, 150);
      analogWrite(ENB, 150);
      break;
      
    case 'G':  // سرعة 255 للخلف
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
      analogWrite(ENA, 0);
      analogWrite(ENB, 255);
      break;
      
    case 'S':  // توقف
    default:
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, LOW);
      analogWrite(ENA, 0);
      analogWrite(ENB, 0);
      break;
  }
}

void