Logic Errors with bool

const int SensorInput = A1;
const int PressInput = A3;

const int PowerOnLEDPin = 7;
const int StatLEDPin = 5;
const int SpliceOccurPin = 2;
const int SpliceCTRL = 8;

const int SenseThreshold = 550;
const int PressThreshold = 550;

bool ChangeOver;

int ledState = LOW;

unsigned long prevCounter = 0;
const long interval = 400;

void setup() {
  
  //Initialize all outputs/inputs for source voltages
  pinMode(SensorInput, INPUT);
  pinMode(PressInput, INPUT);
  pinMode(StatLEDPin, OUTPUT);
  pinMode(PowerOnLEDPin, OUTPUT);
  pinMode(SpliceOccurPin, OUTPUT);
  pinMode(SpliceCTRL, OUTPUT);
    

  //int. serial communications
  Serial.begin(9600);
  Serial.println("Splice Detector: Online");
  digitalWrite(PowerOnLEDPin, HIGH);
  digitalWrite(SpliceCTRL, LOW);
}

void loop() {

int PressValue = analogRead(PressInput);
  
  if (PressValue >= PressThreshold)  {
    digitalWrite(StatLEDPin, LOW);
    digitalWrite(SpliceOccurPin, LOW);
    delay(1000);
    digitalWrite(StatLEDPin, HIGH);
    digitalWrite(SpliceOccurPin, HIGH);
    delay(1000);
    digitalWrite(StatLEDPin, LOW);
    digitalWrite(SpliceOccurPin, LOW);
    delay(1000);
    digitalWrite(StatLEDPin, HIGH);
    digitalWrite(SpliceOccurPin, HIGH);
    Serial.println("ROLL CHANGE IN PROGRESS.  Awaiting Splice...");
    Serial.println("Press Value: " + PressValue);
    ChangeOver = true;
    return;
  }

  
  //Check reference voltage == signal wire
int MeasuredValue = analogRead(SensorInput);

  if (MeasuredValue >= SenseThreshold) {

  if (ChangeOver == true) {
    
    ChangeOver = false;

    digitalWrite(StatLEDPin, LOW);
    digitalWrite(SpliceOccurPin, LOW);
    delay(850);
    digitalWrite(StatLEDPin, HIGH);
    digitalWrite(SpliceOccurPin, HIGH);
    delay(850);
    digitalWrite(StatLEDPin, LOW);
    digitalWrite(SpliceOccurPin, LOW);
    delay(850);
    digitalWrite(StatLEDPin, HIGH);
    digitalWrite(SpliceOccurPin, HIGH);
    delay(850);
    digitalWrite(StatLEDPin, LOW);
    digitalWrite(SpliceOccurPin, LOW);
    Serial.println("ROLL CHANGE SPLICE DETECTED.  System returned to READY MODE");
    Serial.println(MeasuredValue);
    return;
    
    }else{
      
    //Procedure for high voltage potential present at signal wire
    digitalWrite(SpliceOccurPin, HIGH);
    Serial.println(MeasuredValue);
    digitalWrite(StatLEDPin, LOW);
    Serial.println("Status Light Off, Detected Splice");
    digitalWrite(SpliceCTRL, HIGH);
    Serial.println("Sounding Buzzer");
    delay(1500);
    digitalWrite(SpliceCTRL, LOW);
    digitalWrite(StatLEDPin, HIGH);
    digitalWrite(SpliceOccurPin, LOW);
    Serial.println("System in STANDBY MODE");
    delay(10000);
    Serial.println("System returned to READY MODE");
    ChangeOver = false;
    return;
    }
  } else {


    
    //assign values to millisecond counter
    unsigned long currCounter = millis();


//Upon installment of input wire from press **updated 6.6.2016**    
    if (ChangeOver == true){
      return;
      
    }else{
      
    //verify values against recommended interval
    if (currCounter - prevCounter >= interval) {
      prevCounter = currCounter;
      if (ledState == LOW) {
        ledState = HIGH;
      } else {
        ledState = LOW;
      }

      // set the LED with the ledState of the variable
      digitalWrite(StatLEDPin, ledState);
    }
   }
  }
 }

For what ever reason when I run this code on my project it will mess the logic up with the bool which is the ultimate decision maker for determining the correct procedure to follow. I will admit this code is slop and could use some tidying up but I want to make sure I have the jist of it correct and that I am understanding the logic of the bool data type correctly.

I apologize if you get losted in the if then else statements.

What is the program supposed to do ?
What does it actually do ?

How are the inputs wired ?

the bool which is the ultimate decision maker for determining the correct procedure to follow

You haven't explained what the code is supposed to do (i.e. the correct procedure) and what it is doing wrong.
But I think you'll find that the bool has little or nothing to do with it.

 pinMode(SensorInput, INPUT);
  pinMode(PressInput, INPUT);

This makes those two pins digital inputs but you are using them with analogRead.
Remove those two statements and try again.

Pete

This makes those two pins digital inputs

Are you sure ?
They default to INPUT anyway and it is the use of analogRead() or digitalRead() that determines whether they return an analogue or digital value.

Hmmm. I had a vague memory that if you set pinMode INPUT, then analogRead would only return 0 or 1023.

Pete

honduh22:
I will admit this code is slop and could use some tidying up

Please tidy it up and repost.

the code is incorporated with a vision camera. The vision camera will supply a voltage signal to the SensorInput when it detects a certain contrast change. The code will close a relay with the spliceCTRL and turn a buzzer on then off. If it receives a signal from the Press Input it is to wait until it sees the contrast change not set the buzzer off flip the bool and continue watching for the contrast change. the milli timer at the bottom is to blink an led to signify the status of the logic. The LEDs, whether solid, off or flashing are reference to operator the state of the device.

When you tidy up the program for repost, please include the explanation you typed above into the program as comment lines.

Place each { on it's own line and auto format using ctrl-T.

el_supremo:
Hmmm. I had a vague memory that if you set pinMode INPUT, then analogRead would only return 0 or 1023.

Pete

Not true. Setting them INPUT is safe, if unnecessary (unless you set it output earlier for some strange reason, in which case you must set it input first)

If the pin is not capable of analog input, you get 0 or 1023.

If the pin is not capable of analog input, you get 0 or 1023.

That must be what I was thinking of.

Thanks.

Pete