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

Arduino-Controlled Robotic Vehicle with Flame Sensors and Air Pump

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Robotic Vehicle with Flame Sensors and Air Pump

Circuit Documentation

Summary

The circuit in question is designed to control a set of motors and a mini air pump, with inputs from flame sensors and a servo motor for directional control. The brain of the circuit is an Arduino UNO microcontroller, which processes sensor inputs and controls the actuators accordingly. The circuit includes a motor driver (L298N) to manage the high-current demands of the motors, and a Darlington transistor (TIP120) to control the mini air pump. Power is supplied by a 9V battery, and a rocker switch is used to turn the circuit on and off. A diode and a ceramic capacitor are included for protection and noise reduction.

Component List

Wiring Details

Motor Amarillo Motorreductor Hobby

L298N DC Motor Driver

Mini Air Pump

Sensor SHT113 Flame

Arduino UNO

9V Battery

Ceramic Capacitor

Servomotor MG90S

Rocker Switch

Diode

TIP120 Hi-Current Darlington Transistor

Resistor

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) {
    digitalWrite(pump, 0);
    forword();
  }
  else if (s3 >= 251 && s3 <= 700) {
    digitalWrite(pump, 0);
    back