Arduino UNO-Based Fire Detection and Extinguishing Robot with Flame Sensors and Servo Motors
View and Edit Project In Cirkit Designer
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
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
Micro Servo 9G
- Description: Small servo motor for precise control.
- Pins: GND, +5V, PWM
KY-026 Flame Sensor
- Description: Sensor module for detecting flame.
- Pins: A0, GND, VCC, D0
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
Motor with Reducer
- Description: DC motor with a gear reducer.
- Pins: 3 - 6 VCC, GND
Battery 12V
- Description: 12V battery for powering the circuit.
- Pins: +, -
V_REG_LD1117VXX
- Description: Voltage regulator for providing stable 5V output.
- Pins: GND, OUT, IN
Wiring Details
Arduino UNO
- 5V: Connected to V_REG_LD1117VXX (OUT)
- GND: Connected to multiple components' GND pins
- A0: Connected to KY-026 Flame Sensor (A0)
- A1: Connected to KY-026 Flame Sensor (A0)
- A2: Connected to KY-026 Flame Sensor (A0)
- D11: Connected to Micro Servo 9G (PWM)
- D10: Connected to Puente H Carrito (ENA)
- D9: Connected to Puente H Carrito (IN1)
- D8: Connected to Puente H Carrito (IN2)
- D7: Connected to Puente H Carrito (IN3)
- D6: Connected to Puente H Carrito (IN4)
- D5: Connected to Puente H Carrito (ENB)
- D4: Connected to Micro Servo 9G (PWM)
- D3: Connected to Micro Servo 9G (PWM)
- D2: Connected to Micro Servo 9G (PWM)
Micro Servo 9G
- GND: Connected to Arduino UNO (GND)
- +5V: Connected to V_REG_LD1117VXX (OUT)
- PWM: Connected to Arduino UNO (D11, D4, D3, D2)
KY-026 Flame Sensor
- A0: Connected to Arduino UNO (A0, A1, A2)
- GND: Connected to Arduino UNO (GND)
- VCC: Connected to V_REG_LD1117VXX (OUT)
Puente H Carrito
- 12V: Connected to V_REG_LD1117VXX (IN)
- GND: Connected to Arduino UNO (GND)
- ENA: Connected to Arduino UNO (D10)
- IN1: Connected to Arduino UNO (D9)
- IN2: Connected to Arduino UNO (D8)
- IN3: Connected to Arduino UNO (D7)
- IN4: Connected to Arduino UNO (D6)
- ENB: Connected to Arduino UNO (D5)
Motor with Reducer
- 3 - 6 VCC: Not connected in the provided net list
- GND: Not connected in the provided net list
Battery 12V
- +: Connected to V_REG_LD1117VXX (IN)
- -: Connected to V_REG_LD1117VXX (GND)
V_REG_LD1117VXX
- GND: Connected to Battery 12V (-)
- OUT: Connected to Arduino UNO (5V), Micro Servo 9G (+5V), KY-026 Flame Sensor (VCC)
- IN: Connected to Battery 12V (+), Puente H Carrito (12V)
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