Go Down

Topic: Adding a Delay To a "Bin Loading System" (Read 564 times) previous topic - next topic

concretefreak


I've included a copy of the code I'm working on.......I tried inserting a "delay", but this function is not ideal for my application.
I was hoping to insert a pause between "conv1Start" and "aggbinGate1".  The delay function works good but it effects the other part of the program.
I've looked at the "Blink WithoutDelay" function but I'm not sure this will due it the trick as I'm only interested in inserting a pause between to outputs and NOT trying to blink an led...?   Is there any other function out there that would allow a pause between outputs without effecting the rest of the code?


Code: [Select]

      const int conv1Start     =47;
     
      const int turnheadStart  =48;
     
     
      const int aggbinGate1    =49;
      const int aggbinGate2    =50;
      const int aggbinGate3    =51;
     
      const int binhighLed1    =22; //  defines all OUTPUT pins to be connected to LED 1-3
      const int binhighLed2    =23;
      const int binhighLed3    =24;
     
      const int binlowRelay1   =25; //  defines all INPUT pins to be connected to INPUT IO's 1-3
            int Relay1         =0;
      const int binlowRelay2   =26;
            int Relay2         =0;
      const int binlowRelay3   =27;
            int Relay3         =0;
     
      const int turnheadBin1   =28; // sets all digital pins to INPUT state for each BIN high INPUT relay
            int Bin1           =0;
      const int turnheadBin2   =29;
            int Bin2           =0;
      const int turnheadBin3   =30;
            int Bin3           =0;
     
         
  void setup ()
       
    {
       pinMode(conv1Start,   OUTPUT);
       digitalWrite(47, HIGH);
       pinMode(turnheadStart, OUTPUT);
       digitalWrite(48, HIGH);
       
       
       pinMode(aggbinGate1,  OUTPUT);
       pinMode(aggbinGate2,  OUTPUT);
       pinMode(aggbinGate3,  OUTPUT);
       
       pinMode(binhighLed1,  OUTPUT); // sets all digital pins to OUTPUT state for each BIN high LED indicator
       pinMode(binhighLed2,  OUTPUT);
       pinMode(binhighLed3,  OUTPUT);
       
       pinMode(binlowRelay1, INPUT); // sets all digital pins to INPUT state for each BIN high INPUT relay
       pinMode(binlowRelay2, INPUT);
       pinMode(binlowRelay3, INPUT);
       digitalWrite(25, HIGH);
       digitalWrite(26, HIGH);
       digitalWrite(27, HIGH);
       
       
       pinMode(turnheadBin1, INPUT); // sets all digital pins to INPUT state for each BIN high INPUT relay
       pinMode(turnheadBin2, INPUT);
       pinMode(turnheadBin3, INPUT);
       digitalWrite(28, HIGH);
       digitalWrite(29, HIGH);
       digitalWrite(30, HIGH);
   
    }
   
   
    void loop()
    {
        Relay1 = digitalRead(binlowRelay1); Bin1 = digitalRead(turnheadBin1);
        Relay2 = digitalRead(binlowRelay2); Bin2 = digitalRead(turnheadBin2);
       
        if  ((Relay1 == LOW) && (Bin1 == LOW))
              {digitalWrite(conv1Start, LOW);
               delay(4000);
               digitalWrite(aggbinGate1, LOW);}
       
        else if  ((Relay2 == LOW) && (Bin2 == LOW))
              {digitalWrite(conv1Start, LOW);
               delay(4000);
               digitalWrite(aggbinGate2, LOW);}
           
        else
           {digitalWrite(aggbinGate1, HIGH);
            digitalWrite(aggbinGate2, HIGH);
            delay(15000);
            digitalWrite(conv1Start, HIGH);}
       
   
               
    }
 
 


Thank you!!

PaulS

Quote
Is there any other function out there that would allow a pause between outputs without effecting the rest of the code?

No.

Quote
I've looked at the "Blink WithoutDelay" function but I'm not sure this will due it the trick as I'm only interested in inserting a pause between to outputs and NOT trying to blink an led...?

The blink without delay example shows you how to do something later, without the need to use delay().

concretefreak

hhhhmmmm....I'll give it another look....thank you!!

concretefreak


Quote
Is there any other function out there that would allow a pause between outputs without effecting the rest of the code?

No.

Quote
I've looked at the "Blink WithoutDelay" function but I'm not sure this will due it the trick as I'm only interested in inserting a pause between to outputs and NOT trying to blink an led...?

The blink without delay example shows you how to do something later, without the need to use delay().



It looks to me as this example is simply showing how to blink an led, and this is not quite what I'm looking to accomplish, is there a way to manipulate this example to provide a pause between to digitalWrite functions?

PaulS

Quote
It looks to me as this example is simply showing how to blink an led, and this is not quite what I'm looking to accomplish, is there a way to manipulate this example to provide a pause between to digitalWrite functions?

It is not. It is showing how to do something - turn and LED on or off - and then later do something else - turn the LED off or on. You want to set a pin HIGH and then sometime later set another pin HIGH. That is NO different then some time later setting the same pin LOW, except that the pin number changes.

Go Up