Introduction: How to Track Fire With Flame Sensor

Picture of How to Track Fire With Flame Sensor

How do we track fire using 8 Channel Flame Sensor that will be driven by servo motor?

The workflow of this fire tracking is the reading of 8 Channel Flame Sensor simultaneously, and then searched for the smallest flame value using the MIN function of the Arduino. Why do we use the smallest? Because the closer the source of flame, the smaller the value will be generated.

After searching for the smallest value, it will then look for the position on which the Flame Sensor detects the flame, which will serve as the reference point of movement of the servo motor. If the first flame sensor is read, then the servo movement will go to 180 degrees. If the 8th flame sensor is read, then the servo will move to 0 degrees.

Step 1: Materials You Need

Picture of Materials You Need

Step 2: Setup

Picture of Setup

Connect SFE 8 Channel Flame Sensor, SFE Minsys Atmega8 with Serial, and SG-5010 Servo Motor with jumper wires as schematic above or configuration pin below:

  • A0 = A Flame Sensor
  • A1 = B Flame Sensor
  • A2 = C Flame Sensor
  • Data Servo = 10

Step 3: Code

Picture of Code

First, declaration the pin to use:

#define selectorA A0
#define selectorB A1
#define selectorC A2


And then, port initialization used:

Servo myservo; // create servo object to control a servo
void setup()
{

Serial.begin(9600);
pinMode(selectorA, OUTPUT);
pinMode(selectorB, OUTPUT);
pinMode(selectorC, OUTPUT); myservo.attach(9); // attaches the servo on pin 9 to the servo object

}

Create a function to enable the selector and read the flame sensor:

int valFlame[8];
void activeSelector(int a, int b, int c)
{

digitalWrite(selectorA, a);
digitalWrite(selectorB, b);
digitalWrite(selectorC, c);

}

void readFlame()

{

activeSelector(0,0,0);
valFlame[0] = analogRead(A3);
activeSelector(0,0,1);
valFlame[1] = analogRead(A3);
activeSelector(0,1,0);
valFlame[2] = analogRead(A3);
activeSelector(0,1,1);
valFlame[3] = analogRead(A3);
activeSelector(1,0,0);
valFlame[4] = analogRead(A3);
activeSelector(1,0,1);
valFlame[5] = analogRead(A3);
activeSelector(1,1,0);
valFlame[6] = analogRead(A3);
activeSelector(1,1,1);
valFlame[7] = analogRead(A3);

}


The main program, this program will find the minimum value and then be used as a reference error for servo movement.

int minVal=1024;
int error;
void loop()
{

for(int i=0; i<=7; i++)
{

readFlame();
minVal = min(minVal, valFlame[i]);
if(minVal == valFlame[i])
{

error = i;

}

}

myservo.write(error*23);

}


In the above program, the servo will be given the pulse width according to error * 23. The value of 23 is taken due to the maximum degree of servo 180 and the number of 8 sensors, so that 180/8 = 22.5 will be rounded to 23.

Step 4: Check the Video to Know More

Comments

About This Instructable

145views

3favorites

License:

Bio: Electronics Component - PCB [Design, Printing, Inserting] - Electronic Programming
More by sfeelectronics:ON/OFF Timer for Smart HomeHow to Control 8 LEDs Module With MUX BreakoutHow to Track Fire With Flame Sensor
Add instructable to: