Arduino UNO Controlled Flame-Sensing Robot with L298N Motor Driver and Servo Actuation
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit in question appears to be designed for a robotic application that involves motor control, air pumping, flame sensing, and audible signaling. An Arduino UNO microcontroller serves as the central processing unit, interfacing with various sensors, actuators, and a motor driver. The circuit includes flame sensors for detecting fire, a DC motor driver for controlling motors, a servo motor for precise angular movement, a mini air pump, a buzzer for audio feedback, and a power supply provided by a 9V battery. The circuit is designed to react to flame detection with specific movements and actions, including motor speed adjustments and air pump activation.
Component List
- Motor Amarillo Motorreductor Hobby: A DC motor used for driving mechanisms in the robot.
- L298N DC Motor Driver: An H-bridge motor driver that allows for controlling the direction and speed of two DC motors.
- Mini Air Pump: A small pump used for air displacement, possibly for inflation or suction purposes.
- Sensor SHT113 Flame: A flame sensor capable of detecting fire through infrared light.
- Arduino UNO: A microcontroller board based on the ATmega328P, used for controlling the logic of the circuit.
- 9V Battery: A power source for the circuit.
- Ceramic Capacitor: A passive component used for filtering and stabilizing the electrical signal.
- Rocker Switch: A switch used to control the power flow in the circuit.
- Resistor: A passive component used to limit current or divide voltages in the circuit.
- Servomotor MG90S: A small servo motor for precise control of angular position.
- LED (Red): A light-emitting diode used for visual signaling.
- Buzzer: An electromechanical component used for audible signaling.
Wiring Details
Motor Amarillo Motorreductor Hobby
- VCC: Connected to the output of the L298N motor driver.
- GND: Connected to the common ground net in the circuit.
L298N DC Motor Driver
- OUT1, OUT2, OUT3, OUT4: Connected to the VCC and GND pins of the DC motors.
- 12V: Connected to the 9V battery through a rocker switch.
- GND: Connected to the common ground net in the circuit.
- 5V: Not connected in the provided net list.
- ENA, ENB: Controlled by the Arduino UNO for speed control of the motors.
- IN1, IN2, IN3, IN4: Controlled by the Arduino UNO for direction control of the motors.
Mini Air Pump
- PIN1: Connected to the 9V battery through a rocker switch.
- PIN2: Connected to the common ground net in the circuit.
Sensor SHT113 Flame
- A0: Connected to the analog pins A0, A1, and A2 of the Arduino UNO for flame detection.
- D0: Connected to the buzzer and the common ground net in the circuit.
- GND: Connected to the common ground net in the circuit.
- VCC: Connected to the 5V output of the Arduino UNO.
Arduino UNO
- Digital and Analog Pins: Connected to various components for control and sensing.
- 5V and GND: Provide power to the flame sensors and servo motor.
- Vin: Connected to the 9V battery through a rocker switch.
9V Battery
- +: Connected to the rocker switch.
- -: Connected to the common ground net in the circuit.
Ceramic Capacitor
- Pin0: Connected to the 9V battery through a rocker switch.
- Pin1: Connected to the common ground net in the circuit.
Rocker Switch
- Input: Connected to the 9V battery.
- Output: Connected to the Vin pin of the Arduino UNO and the 12V input of the L298N motor driver.
Resistor
- Pin1: Not connected in the provided net list.
- Pin2: Connected to the A5 pin of the Arduino UNO.
Servomotor MG90S
- SIG: Controlled by the A4 pin of the Arduino UNO.
- VCC: Connected to the 5V output of the Arduino UNO.
- GND: Connected to the common ground net in the circuit.
LED (Red)
- Cathode: Connected to the common ground net in the circuit.
- Anode: Connected to the 9V battery through a rocker switch.
Buzzer
- PIN: Connected to the D0 pin of the flame sensors.
- GND: Connected to the common ground net in the circuit.
Documented Code
#define enA 10 // Enable1 L298 Pin enA (Motor1 Speed Control)
#define in1 9 // Motor1 L298 Pin in1 (Motor1 Forward)
#define in2 8 // Motor1 L298 Pin in2 (Motor1 Backward)
#define in3 7 // Motor2 L298 Pin in3 (Motor2 Forward)
#define in4 6 // Motor2 L298 Pin in4 (Motor2 Backward)
#define enB 5 // Enable2 L298 Pin enB (Motor2 Speed Control)
#define ir_R A0 // Right Infrared sensor
#define ir_F A1 // Front Infrared sensor
#define ir_L A2 // Left Infrared sensor
#define servo A4 // Servo Motor pin
#define pump A5 // Pump control pin
int Speed = 160; // Duty Cycle (0 to 255) for motor speed control
int s1, s2, s3; // Variables to store sensor readings
void setup() {
Serial.begin(9600); // Start serial communication at 9600 bps
pinMode(ir_R, INPUT); // Set right sensor as input
pinMode(ir_F, INPUT); // Set front sensor as input
pinMode(ir_L, INPUT); // Set left sensor as input
pinMode(enA, OUTPUT); // Motor1 speed control
pinMode(in1, OUTPUT); // Motor1 forward
pinMode(in2, OUTPUT); // Motor1 backward
pinMode(in3, OUTPUT); // Motor2 forward
pinMode(in4, OUTPUT); // Motor2 backward
pinMode(enB, OUTPUT); // Motor2 speed control
pinMode(servo, OUTPUT); // Servo motor control
pinMode(pump, OUTPUT); // Pump control
// Initial servo movements
for (int angle = 90; angle <= 140; angle += 5) {
servoPulse(servo, angle);
}
for (int angle = 140; angle >= 40; angle -= 5) {
servoPulse(servo, angle);
}
for (int angle = 40; angle <= 95; angle += 5) {
servoPulse(servo, angle);
}
// Set initial motor speeds
analogWrite(enA, Speed); // Set Motor1 speed
analogWrite(enB, Speed); // Set Motor2 speed
delay(500);
}
void loop() {
s1 = analogRead(ir_R); // Read right sensor
s2 = analogRead(ir_F); // Read front sensor
s3 = analogRead(ir_L); // Read left sensor
// Display sensor readings on the serial monitor
Serial.print(s1); Serial.print("\t");
Serial.print(s2); Serial.print("\t");
Serial.println(s3);
delay(50);
// Automated control based on sensor input
if (s1 < 250) {
Stop();
digitalWrite(pump, 1);
for (int angle = 90; angle >= 40; angle -= 3) {
servoPulse(servo, angle);
}
for (int angle = 40; angle <= 90; angle += 3) {
servoPulse(servo, angle);
}
}
else if (s2 < 350) {
Stop();
digitalWrite(pump, 1);
for (int angle = 90; angle <= 140; angle += 3) {
servoPulse(servo, angle);
}
for (int angle = 140; angle >= 40; angle -= 3) {
servoPulse(servo, angle);
}
for (int angle = 40; angle <= 90; angle += 3) {
servoPulse(servo, angle);
}
}
else if (s3 < 250) {
Stop();
digitalWrite(pump, 1);
for (int angle = 90; angle <= 140; angle += 3) {
servoPulse(servo, angle);
}
for (int angle = 140; angle >= 90; angle -= 3) {
servoPulse(servo, angle);
}
}
else if (s1 >= 251 && s1 <= 700) {
digitalWrite(pump, 0);
backword();
delay(100);
turnRight();
delay(200);
}
else if (s2 >= 251 && s2 <= 800) {