Can any one offer any positive feedback and/or advice that will allow the code i have below to run and complete each section before moving to the next?
Thank you
Dave Pina
const int conv1 = 47; // output pin the conveyor relay is attached to
const int turnhead = 48; // output pin the turnhead relay is attached to
const int aggHopperGate1 = 49; // output pin the gate1 relay is attached to
const int aggHopperGate2 = 50; // output pin the gate2 relay is attached to
const int aggHopperGate3 = 51; // output pin the gate3 relay is attached to
const int bindicatorlow1 = 25; // input pin for the bin1 low signal
int bindicatorlowstatus1;
const int bindicatorlow2 = 26; // input pin for the bin2 low signal
int bindicatorlowstatus2;
const int bindicatorlow3 = 27; // input pin for the bin3 low signal
int bindicatorlowstatus3;
// Variables will change:
int bindicatorlow1_State; // current state of the aggstoragebindicator1
int last_bindicatorlow1_State; // previous state of the aggstoragebindicator1
const int turnheadBin1 = 28; // input pin for turnhead position1
int turnheadposition1;
const int turnheadBin2 = 29; // input pin for turnhead position2
int turnheadposition2;
const int turnheadBin3 = 30; // input pin for turnhead position3
int turnheadposition3;
// Variables will change:
int turnheadposition1_State;
int turnheadposition2_State;
int turnheadposition3_State;
void setup ()
{
Serial.begin(9600);
// sets all digital pins to OUTPUT state for conv1 and turnhead
pinMode(conv1, OUTPUT);
pinMode(turnhead, OUTPUT);
// sets all digital pins to OUTPUT state for each hopper gate
pinMode(aggHopperGate1, OUTPUT);
pinMode(aggHopperGate2, OUTPUT);
pinMode(aggHopperGate3, OUTPUT);
// sets all digital pins to INPUT state for each bin low INPUT
pinMode(bindicatorlow1, INPUT);
pinMode(bindicatorlow2, INPUT);
pinMode(bindicatorlow3, INPUT);
// Set all binlow input bins to HIGH state
digitalWrite(25, HIGH);
digitalWrite(26, HIGH);
digitalWrite(27, HIGH);
// sets all digital pins to INPUT state for each turnhead position
pinMode(turnheadBin1, INPUT);
pinMode(turnheadBin2, INPUT);
pinMode(turnheadBin3, INPUT);
// Set all trunhead input bins to HIGH state
digitalWrite(28, HIGH);
digitalWrite(29, HIGH);
digitalWrite(30, HIGH);
}
void loop()
{
bindicatorlowstatus1 = digitalRead(bindicatorlow1);
bindicatorlowstatus2 = digitalRead(bindicatorlow2);
bindicatorlowstatus3 = digitalRead(bindicatorlow3);
//################################################## RUN SECETION 1 ###########################################################
if (( bindicatorlowstatus1 == LOW) || (bindicatorlowstatus2 == LOW) || (bindicatorlowstatus3 == LOW)){
digitalWrite(conv1, LOW); //start conveyor 1
delay(2000);
Serial.write("conveyor 1 has started");
if (bindicatorlowstatus1 == LOW){ //if its bindicator 1 thats LOW meaning the material has dropped we fill the plant
digitalWrite(turnhead, LOW); //start turnhead
turnheadposition1_State = digitalRead(turnheadBin1); //read current state of turnhead position for bin 1
if (turnheadposition1_State = LOW){ //if turnhead has reached bin 1 position STOP turnhead
digitalWrite(turnhead, HIGH); //stop turnhead
delay(4000); //wait 4 seconds
digitalWrite(aggHopperGate1, LOW); //open aggHopperGate1
if(bindicatorlowstatus1 == HIGH);{//bin has reached full close gate
digitalWrite(aggHopperGate1, HIGH);//close aggHopperGate1
}
}
}
//##################################### WAIT TILL SECTION 1 IS COMPLETE THEN RUN SECETION 2 ############################################
if (bindicatorlowstatus2 == LOW){ //if its bindicator 1 thats LOW meaning the material has dropped we fill the plant
digitalWrite(turnhead, LOW); //start turnhead
turnheadposition2_State = digitalRead(turnheadBin2); //read current state of turnhead position for bin 1
if (turnheadposition2_State = LOW){ //if turnhead has reached bin 1 position
digitalWrite(turnhead, HIGH); //stop turnhead
delay(4000); //wait 4 seconds
digitalWrite(aggHopperGate2, LOW); //open aggHopperGate1
if(bindicatorlowstatus2 == HIGH);{//bin has reached full limit close gate
digitalWrite(aggHopperGate2, HIGH);//close aggHopperGate1
}
}
}
//######################################## WAIT TILL SECTION 2 IS COMPLETE THEN RUN SECETION 3 ###########################################
if (bindicatorlowstatus3 == LOW){ //if its bindicator 1 thats LOW meaning the material has dropped we fill the plant
digitalWrite(turnhead, LOW); //start turnhead
turnheadposition3_State = digitalRead(turnheadBin3); //read current state of turnhead position for bin 1
if (turnheadposition3_State = LOW){ //if turnhead has reached bin 1 position
digitalWrite(turnhead, HIGH); //stop turnhead
delay(4000); //wait 4 seconds
digitalWrite(aggHopperGate3, LOW); //open aggHopperGate1
if(bindicatorlowstatus3 == HIGH);{//bin has reached full limit close gate
digitalWrite(aggHopperGate3, HIGH);//close aggHopperGate1
}
}
}
}
}
//################################################REPEAT SECTION 1, 2, 3 ###########################################################