#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!