- Vcc to Arduino 5v
- Gnd to Gnd
- AOUT to Arduino Analog Pin Out
- DOUT to Arduino Digital Pin Out
- Led1 Anode pin to Arduino Digital Pin 12 and Cathode Pin to Gnd
- Led2 Anode pin to Arduino Digital Pin 12 and Cathode Pin to Gnd
Programming
- int led1=13;
- int led2=12;
- int buzzer=5;
- const int sensormin=0;
- const int sensormax=1000;
-
- void setup()
- {
- pinMode(led1,OUTPUT);
- pinMode(led2,OUTPUT);
- pinMode(buzzer,OUTPUT);
- Serial.begin(9600);
- }
-
- void loop()
- {
- int sensorReading;
- int range;
- sensorReading=analogRead(A1);
- range=map(sensorReading,sensormin,sensormax,0,3); //Apply the calibration to the sensor reading
- switch(range)
- {
- case 0:
- Serial.println("Close Fire");
- digitalWrite(led1,HIGH);
- digitalWrite(buzzer,HIGH);
- break;
- case 1:
- Serial.println("Distance Fire");
- digitalWrite(led1,LOW);
- digitalWrite(led2,HIGH);
- digitalWrite(buzzer,LOW);
- break;
- case 2:
- Serial.println("No Fire");
- digitalWrite(led1,LOW);
- digitalWrite(led2,LOW);
- digitalWrite(buzzer,LOW);
- break;
- }
- delay(5);
- }
Output
Explanation:
Initialize the pin number to LED and buzzer and for the Fire Sensor we give the const value. Here the value will not be changed in the runtime. In the Setup() function set the pinMode to the LED and buzzer as OUTPUT and set the baudRate as (9600). In loop() function we want to give the conditions for IR Module Flame Sensor based on our condition it will work. Here we are using the switch condition.
- sensorReading=analogRead(A1);
- range=map(sensorReading,sensormin,sensormax,0,3);
Case 0: Close fire // led 1 on and Buzzer Sound.
Case 1: Distance Fire //led1 high and there is no buzzer sound.
Case 2: No Fire //Both led and buzzer are in the off condition.
Based upon the above switch case statement we can find the fire detection using IR Module Flame Sensor.
Conclusion
And finally we made the Automated fire detection using IR Module Flame Sensor