I am attempting to move a stepper motor from the input of two IR flame detectors on my Arduino. Right now my code appears as if theoretically it should work but for some reason it is not working correctly. I think it may be just a simple syntax error, but I know for sure the Arduino is registering the signal coming from the IR sensor as the serial monitor is showing.
#include <Stepper.h> //Starts the stepper library
Stepper RoboticArm(4096, 5, 6, 7, 8); //Sets the number of steps and the interface connection ports
int IRDetector1Output = 10; //IR Detector 1 set to Digital Pin 3
int IRDetector2Output = 11; //IR Detector 2 set to Digital Pin 4
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //Starting the monitor for computer telemetry scripts
pinMode(IRDetector1Output, INPUT);
pinMode(IRDetector2Output, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(IRDetector1Output) == HIGH && digitalRead (IRDetector2Output) == HIGH); //When both IR detectors show vehicle centered, do not move tracking mount
Serial.print("TRACKING ASCENT: CENTER");
{
RoboticArm.setSpeed(0); //RPM set to zero on stepper motor
RoboticArm.step(4096); //Number of steps in stepper motor
Serial.print("TRACKING ASCENT: CENTER");
}
if (digitalRead(IRDetector1Output) == HIGH);
{
RoboticArm.setSpeed(3); //RPM set to 3 upwards to track vehicle
RoboticArm.step(4096); //Number of steps in stepper motor
Serial.print("TRACKING ASCENT: UPWARDS COURSE CORRECTION");
}
if (digitalRead(IRDetector1Output) == LOW);
{
RoboticArm.setSpeed(-3); //RPM set to -3 downwards to track vehicle
RoboticArm.step(4096); //Number of steps in stepper motor
Serial.print("TRACKING ASCENT: DOWNWARDS COURSE CORRECTION");
}
}