0% found this document useful (0 votes)
8 views14 pages

Arduino Fire-Extinguishing Robot Code

Project

Uploaded by

eren04012001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views14 pages

Arduino Fire-Extinguishing Robot Code

Project

Uploaded by

eren04012001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

COMPONENT LIST

[Link](AT MEGA 328) ARDUINO UNO

2.16 pin female socket for controller

3. PCB board

[Link] oscillator(11.0592 MHz)

5.7805 voltage regulator

[Link]

[Link] (1 K-ohm)

[Link] (10uF,22pF(2))

11.L293D Driver with female socket

[Link]

14 dc pump

[Link] (9v)

[Link] wires

[Link] iron

[Link] (required rpm)

[Link] for robot

[Link]

Npn pnp

Fire sencer

Wifi camera

DIGRAM
//Program to

#define LM1 2 //define the pin numbers for motor

#define LM2 3

#define RM1 7

#define RM2 8

int left = 0;

int right = 1;

int centre = 2;

int left_reading = 0;

int right_reading = 0;

int centre_reading = 0;
void moveforward();

void movebackward();

void turnleft();

void turnright();

void robostop();

void setup() //setup function to define the pin Mode whether as input or output for motors and
sensors

[Link](9600);

pinMode(LM1, OUTPUT);

pinMode(LM2, OUTPUT);

pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);

pinMode(13, OUTPUT); // define the pin and mode for motor with fan

pinMode(12, OUTPUT);

void loop() //infinite loop function

// Read the sensor value connected to the analog pins

left_reading = analogRead(left); // A0 pin

[Link]("left = ");

[Link](left_reading);

delay(500);
right_reading = analogRead(right); //A1 pin

[Link]("right = ");

[Link](right_reading);

delay(500);

centre_reading = analogRead(centre); //A2 pin

[Link]("centre = ");

[Link](centre_reading);

delay(500);

if(left_reading > 300) //if condition to check reading of left sensor is high

turnleft();

[Link](".................Left");
delay(1300);

moveforward(); //if high make the robot move forward

[Link](".................Forward");

if(analogRead(centre) > 991) //by reaching near fire sensor value goes high

robostop();

[Link](".................Stop");

digitalWrite(12, HIGH);

digitalWrite(13, LOW);

delay(5000);

digitalWrite(12, LOW);

digitalWrite(13, LOW);
}

delay(1100);

turnright(); // After extinguish the fire turn the robot

[Link](".................Right");

delay(1300);

robostop();

if(right_reading > 400)

turnright();

[Link](".................Right");

delay(1300);
moveforward();

[Link]("................Forward");

if(analogRead(centre) > 991)

robostop();

[Link]("................Stop");

digitalWrite(12, HIGH);

digitalWrite(13, LOW);

delay(5000);

digitalWrite(12, LOW);

digitalWrite(13, LOW);

delay(1100);
turnleft();

[Link](".................Left");

delay(1300);

robostop();

if(centre_reading > 400)

moveforward();

[Link](".................Forward");

if(analogRead(centre) > 991)

robostop();
[Link](".................Stop");

digitalWrite(12, HIGH);

digitalWrite(13, HIGH);

delay(5000);

digitalWrite(12, LOW);

digitalWrite(13, LOW);

#if 1

void moveforward() //function definition to move the robot forward

{
digitalWrite(LM1, HIGH);

digitalWrite(LM2, LOW);

digitalWrite(RM1, HIGH);

digitalWrite(RM2, LOW);

void movebackward() //function definition to move the robot backward

digitalWrite(LM1, LOW);

digitalWrite(LM2, HIGH);

digitalWrite(RM1, LOW);

digitalWrite(RM2, HIGH);

}
void turnleft() //function definition to turn the robot left

digitalWrite(LM1, HIGH);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);

digitalWrite(RM2, LOW);

void turnright() //function definition to turn the robot right

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);
digitalWrite(RM1, HIGH);

digitalWrite(RM2, LOW);

void robostop() //function definition to stop the robot

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);

digitalWrite(RM2, LOW);

#endif

You might also like