My Flame detector is constantly sending a high to digital out..need HELP!!

#include <AFMotor.h>
#include <inttypes.h>
#include <avr/io.h>
#define FLAME_DETECT_ANA A0 // Select the input pin for the flame detectors analogue output
#define FLAME_DETC_DIO 2 // Select the input pin for the flame detectors digital output

AF_DCMotor motor(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

int led = 13; // 555 Timer: Select the input pin for the led

void setup() // Initialize serial and DIO
{
Serial.begin(9600); // set up Serial library at 9600 bps
pinMode(led, OUTPUT);
pinMode(1, MOTOR12_64KHZ);
pinMode(2, MOTOR12_64KHZ);
pinMode(FLAME_DETC_DIO, INPUT); // Configure the DIO pin the sensor’s digital output will be connected to

motor.setSpeed(255); // set the speed to 255/255
motor2.setSpeed(255); // Set the speed to 255/255
}
void loop() // Main program loop
{
Serial.print(analogRead(FLAME_DETECT_ANA));
if (digitalRead(FLAME_DETC_DIO)) //
{
digitalWrite(led, LOW);
delay(5000);
digitalWrite(led, HIGH);

}
else // Otherwise there is no alert and the LED is shut down
{
Serial.println();
digitalWrite(led, HIGH);
delay(60000);
}
{
motor.run(FORWARD); // turn door on going forward for 5 seconds
delay(5000);
motor2.run(FORWARD); // turn pump on going forward only
motor.run(RELEASE); // turn off door motor
delay(5000);

motor2.run(RELEASE); // stop pump

motor.run(BACKWARD); // the other way
delay(5000);

motor.run(RELEASE); // stopped
motor2.run(RELEASE); // stopped

void release(void);
void release(void);

while (1) {}
}
Ok so the issue is we have 2 motors running off a motor sheild with a good program executing what we want as far as timing goes. The issue is we have a flame detector that we are using to trigger a high in order to activate the motor sheild. The flame detector has a 5 second delay set on the sensor yet as soon as the program executes to the end, the flame sensor sends another HIGH without any use of IR, spark or heat!!? Am I missing something in my code above? Please help!

Also if I connect just a led to pin 13 the led will have a very minimal blink every 5 seconds or depending on the delay time set in program. Soon as the led pulsates it initiates the program before any heat or IR has been introduced…if this clarify anything…

So, you can't reliably read data from the mysterious flame detector, but you wrote a buttload of code to use that data. Why?

The point was to initiate a HIGH value through the flame detector to Control fire suppression aspects of a project..ie fire damper door, water pump and strobe flashers. Everything is working except the flame detector code. I just need some ideas not condescending responses.

One idea that is commonly put forward in this forum, is to get the individual pieces of a project working to your satisfaction, before putting everything together.

Applying this principle to your situation, write a very simple program that just reads the flame detector. If it doesn't work, it would be much easier for you and other people to see or guess what the problem might be.

I just need some ideas not condescending responses.

A condescending remark might have been something like "Well, you idiot, what the hell is all that code that can't possibly work there for?". I said nothing like that.

As jremington says, create a small sketch to just test the sensor (which is what I was hinting at). Also, post a link to the sensor you are using, so we can confirm (or refute) that you are reading it correctly.

These lines are going to get you into trouble:

#define FLAME_DETECT_ANA A0 // Select the  input pin for the flame detectors analogue output
#define FLAME_DETC_DIO 2    // Select the input pin for the flame detectors digital output

Subtitution for #define is textual: Everything on the line following the first parameter will be substituted into the code submitted to the compiler... even the comments. This is going to wipe out any parentheses or semicolons or anything else on the line.

Lose the comments on the #define lines, or at least move them to a different place!

I am amazed that the code compiled... or did it?

void release(void);
    void release(void);

Strange place for prototypes.

(Did you notice the use of CODE TAGS there?)

vaj4088:
These lines are going to get you into trouble:

#define FLAME_DETECT_ANA A0 // Select the  input pin for the flame detectors analogue output

#define FLAME_DETC_DIO 2    // Select the input pin for the flame detectors digital output




Subtitution for #define is textual: Everything on the line following the first parameter will be substituted into the code submitted to the compiler... even the comments.

Crap.

pinMode(1, MOTOR12_64KHZ);

????? you can choose INPUT or OUTPUT or INPUT_PULLUP, so why aren't you using any of them.

"Crap." -- a bit cryptic!

I've wondered about comments on #define statements too. So, I looked up what the gcc preprocessor actually does in this case. According to Initial processing (The C Preprocessor) one of the very first actions taken by the preprocessor is to replace each comment with a single blank space. So, if a blank space is OK on a #define statement, //comments should be too.

jremington:
"Crap." -- a bit cryptic!

I prefer "concise".

Yes the code does compile just fine. And if I run strictly the flame detector code to a standard led output it acts like it's suppose to..goes HIGH when flame is introduced and turns led on..The program also latches the LED output to remain on for one minute after signal is received. The problem that is occurring is that once the remaining code is entered for the motor controls the Flame detector kicks the program into run mode after 5 seconds..happens every time. Other than that the program runs flawlessly as far as the timing controls on the motors are concerned.

Sorry for the snappy remark earlier but this thing is driving me crazy. Spent several hours over the last few days modifying the code to get a different result. Any help is greatly appreciated.

Did you read reply #9?

Have you got any debug prints?
What do they tell you?

Thank you for correcting my reply #6.

As Reply #2 says, your fundamental problem is that you aren't getting accurate data from the flame detector. Unless and until you do that, anything else your sketch does is pointless. Write a test sketch that does nothing but test the input, and get that working accurately before you go any further.

Ok will Do. thanks

Ok so almost a week later I'm still having the same issue. I wrote a code specifically for the flame sensor and connected it directly to an LED to verify..Also I ran the serial screen to verify values. Everything works until I place the flame sensor code into the main program. I even adjusted to if and else statements to no avail. Main question is is the DO port necessary? Can I use analog only on the flame sensor and still output a high on my uno? I'm having the same reoccurring issue with this code causing pin 13 to go high and immediately initiate my program without the presence of flame! Help please!

Your program looks quite bogus with all those long delay() calls in it. I would not use those.

What does the analog output from the flame detector do ?

I don't know about your sensor, but many sensors which work this way, have an adjustment on the sensor , so that you can adjust the level at which the digital on/off output is triggered. You might need to adjust this, so that it only triggers at a level which corresponds to an actual flame.