Show Posts
Pages: 1 ... 13 14 [15] 16 17 ... 20
211  Using Arduino / Project Guidance / Re: heating control on: June 01, 2012, 04:16:39 pm
Quote
What exactly are you trying to accomplish with this part?
im trying just to do the delay without delay at the moment

Quote
 
Also, the "check if it's been long enough" code will only run if your button is HIGH. Is that your intention? In other words, fan won't go low unless it's been long enough AND heatbutton is HIGH.

my intention is to delay the fan when turning off so when the heat button goes from high to low it will delay.

but i do want to include as i said earlier that the time delay is dependent on the time the heat button has been high upto a set time.
212  Using Arduino / Project Guidance / Re: heating control on: June 01, 2012, 03:35:09 pm
ok i have had a bit off a play with this (again lol)  this seem to work but did miss the delay a couple of times but this is just on a test rig at mo so mite be ok then installed what do you think?

this is just delay with out delay at mo

Code:


const int heatbutton     = 2 ;
const int ignition_fan_2 = 10;
const int saleswitch     = 4 ;
const int solenoid       = 12;
const int photo_pressure = 3 ;
const int lockoutled     = 8 ;
const int heatbutton_feed= 5 ;
const int fan            = 9 ;
const int relay230_24    = 11;
const int ionisation_in  = 7 ;
int ionisation           = 5 ;   
bool DoneInitialization = false;       
int fandelay = LOW;
long previousMillis = 0;
long interval = 30000;
void setup()
{
  pinMode(heatbutton,       INPUT );   
  pinMode(ignition_fan_2,   OUTPUT);
  pinMode(saleswitch,       INPUT );
  pinMode(solenoid,         OUTPUT);
  pinMode(photo_pressure,   INPUT );
  pinMode(lockoutled,       OUTPUT);
  pinMode(heatbutton_feed,  OUTPUT);
  pinMode(fan,              OUTPUT);
  pinMode(relay230_24,      OUTPUT);
  pinMode(ionisation_in,    INPUT );
  //-------------------------------------------
  digitalWrite(heatbutton_feed, HIGH);
}

void loop() {
  int val = analogRead(ionisation);
  //--------------------------------------------------------------------

  if (digitalRead(heatbutton)==        HIGH) {
    delay(10);    //debounce
    if (!DoneInitialization)
    {                                                 
      if (digitalRead(ionisation_in)==   HIGH) {           // if ionisation swith HIGH
        if (val >900) {                                       
          digitalWrite(lockoutled,            HIGH);
         delay(10);
          digitalWrite(heatbutton_feed,       LOW);
          return;
        }
      }   
      else {
        if (digitalRead(photo_pressure)==     HIGH) {         // if photo swith HIGH
        delay(10);
          digitalWrite(lockoutled,            HIGH);
         delay(10);         
          digitalWrite(heatbutton_feed,       LOW);
         return;
       }
      }
      digitalWrite(fan,                    HIGH);
      delay(3000);       
     
    //---------------------------------------------------------------------
    if (digitalRead(saleswitch)==HIGH) {           // sale switch if HIGH
    digitalWrite(relay230_24,    HIGH);        // 230V out put to ignition
    digitalWrite(ignition_fan_2, HIGH);
    delay(1000);
      digitalWrite(solenoid,     HIGH);
    }
    DoneInitialization=true;                           // Initialization is done, don't run it again until button has been low
    }
    //---------------------------------------------------------------------
    if (digitalRead(saleswitch)==   LOW) {          // sale switch if LOW
      digitalWrite(lockoutled,      HIGH);
      digitalWrite(solenoid,        LOW);
      digitalWrite(fan,             LOW);
       delay(10);
      digitalWrite(heatbutton_feed, LOW);
    }
    //---------------------------------------------------------------------
    delay(3000);
    if (digitalRead(ionisation_in)== HIGH) {
      if (val <900)                         {            // ionisation if LOW
        digitalWrite(lockoutled,      HIGH);
        delay(10);
        digitalWrite(heatbutton_feed, LOW);
      }
    }

    if (digitalRead(photo_pressure)==LOW)  {          // photo if LOW
      delay(10);
      digitalWrite(lockoutled,       HIGH);
      delay(10);
      digitalWrite(heatbutton_feed,  LOW);
    }
    //---------------------------------------------------------------------
    else {
      digitalWrite(ignition_fan_2, LOW);
    }
  }
    //---------------------------------------------------------------------
    else {                                          // switching off
    digitalWrite(solenoid,       LOW);
    digitalWrite(ignition_fan_2, LOW);
    DoneInitialization=false;                    // resetting the count
    delay(500);
    digitalWrite(relay230_24,    LOW);
          unsigned long currentMillis = millis();
   if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
  if (fandelay == LOW)
    digitalWrite(fan, LOW);
      digitalWrite(fan, fandelay);
  }
    }
  //---------------------------------------------------------------------
}

213  Using Arduino / Project Guidance / Re: heating control on: June 01, 2012, 02:05:16 pm
hi thanks for your reply
i have looked at blink without delay and cannot get to grips with it
214  Using Arduino / Project Guidance / heating control on: June 01, 2012, 12:45:27 pm
hi there
on this heating project i'm doing when the control is turned off the fan will run for 30 secs  but one problem i have is it will not start back up until the 30 secs are up what is not good?
and what i would like to do aswel i would like to have the delay variable so if the heater has been running for 20secs the over run with be 20 secs but max over run to be 30secs?

i had come across this for the variable over run but could not intergrate this into my code and make it still work and it does not have a max over run to
Quote

const int switchPin = 2;
const int led = 13;

long startTime;
long duration;

void setup()
{
  pinMode(switchPin,        INPUT);
  digitalWrite(switchPin,   HIGH);
  pinMode(led,            OUTPUT);
}

void loop()
{
  if(digitalRead(switchPin) ==     HIGH)
  {
    digitalWrite(led,              HIGH);
  }

  if(digitalRead(switchPin) ==     HIGH)
  {
    startTime = millis();
    while(digitalRead(switchPin) ==HIGH)
      ;
    long duration = millis() - startTime;
    delay(duration);
    digitalWrite(led,             LOW);
  }
}



this is my code
where the yellow glow saying  //   THIS IS WHERE MY DELAY IS  this is where my delay is at mo

Quote

const int heatbutton     = 2 ;
const int ignition_fan_2 = 10;
const int saleswitch     = 4 ;
const int solenoid       = 12;
const int photo_pressure = 3 ;
const int lockoutled     = 8 ;
const int heatbutton_feed= 5 ;
const int fan            = 9 ;
const int relay230_24    = 11;
const int ionisation_in  = 7 ;
int ionisation           = 5 ;   
bool DoneInitialization = false;       

void setup()
{
  pinMode(heatbutton,       INPUT );   
  pinMode(ignition_fan_2,   OUTPUT);
  pinMode(saleswitch,       INPUT );
  pinMode(solenoid,         OUTPUT);
  pinMode(photo_pressure,   INPUT );
  pinMode(lockoutled,       OUTPUT);
  pinMode(heatbutton_feed,  OUTPUT);
  pinMode(fan,              OUTPUT);
  pinMode(relay230_24,      OUTPUT);
  pinMode(ionisation_in,    INPUT );
  //-------------------------------------------
  digitalWrite(heatbutton_feed, HIGH);
}

void loop() {
  int val = analogRead(ionisation);
  //--------------------------------------------------------------------

  if (digitalRead(heatbutton)==        HIGH) {
    delay(10);    //debounce
    if (!DoneInitialization)
    {                                                 
      if (digitalRead(ionisation_in)==   HIGH) {           // if ionisation swith HIGH
        if (val >900) {                                       
          digitalWrite(lockoutled,            HIGH);
          delay(10);
          digitalWrite(heatbutton_feed,       LOW);
          return;
        }
      }   
      else {
        if (digitalRead(photo_pressure)==     HIGH) {         // if photo swith HIGH
          delay(10);
          digitalWrite(lockoutled,            HIGH);
          delay(10);         
          digitalWrite(heatbutton_feed,       LOW);
          return;
        }
      }
      digitalWrite(fan,                    HIGH);
      delay(3000);       

      //---------------------------------------------------------------------
      if (digitalRead(saleswitch)==HIGH) {           // sale switch if HIGH
        digitalWrite(relay230_24,    HIGH);        // 230V out put to ignition
        digitalWrite(ignition_fan_2, HIGH);
        delay(1000);
        digitalWrite(solenoid,     HIGH);
      }
      DoneInitialization=true;                           // Initialization is done, don't run it again until button has been low
    }
    //---------------------------------------------------------------------
    if (digitalRead(saleswitch)==   LOW) {          // sale switch if LOW
      digitalWrite(lockoutled,      HIGH);
      digitalWrite(solenoid,        LOW);
      digitalWrite(fan,             LOW);
      delay(10);
      digitalWrite(heatbutton_feed, LOW);
    }
    //---------------------------------------------------------------------
    delay(3000);
    if (digitalRead(ionisation_in)== HIGH) {
      if (val <900)                         {            // ionisation if LOW
        digitalWrite(lockoutled,      HIGH);
        delay(10);
        digitalWrite(heatbutton_feed, LOW);
      }
    }

    if (digitalRead(photo_pressure)==LOW)  {          // photo if LOW
      delay(10);
      digitalWrite(lockoutled,       HIGH);
      delay(10);
      digitalWrite(heatbutton_feed,  LOW);
    }
    //---------------------------------------------------------------------
    else {
      digitalWrite(ignition_fan_2, LOW);
    }
  }
  //---------------------------------------------------------------------
  else {                                          // switching off
    digitalWrite(solenoid,       LOW);
    digitalWrite(ignition_fan_2, LOW);
    DoneInitialization=false;                    // resetting the count
    delay(500);
    digitalWrite(relay230_24,    LOW);
    delay(30000);                            //   THIS IS WHERE MY DELAY IS
    digitalWrite(fan,            LOW);       //   THIS IS WHERE MY DELAY IS
  }
  //---------------------------------------------------------------------

}





215  Using Arduino / Project Guidance / Re: timing within a loop on: May 20, 2012, 08:07:15 am
thanks wildbill for that. that side of it is working perfectly now.

with this next issue ive got it wrapped round my head now and im not understanding it?
216  Using Arduino / Project Guidance / Re: timing within a loop on: May 14, 2012, 10:14:08 am
Quote



Looks like.

Having said that

Code:

if(count == 1) count =0;       // resetting the count

Why check count? You can unconditionally set it zero (either it was already zero, or it's one and you want it to be zero)

Also, given that count can only take two values, shouldn't it be a boolean?


honestly i havent got a clue show me what you mean


Quote

I don't understand, was there a question?

yes sorry finding it hard to explain basically when the switch is turned off theres to be a delay before the LED goes off but the delay depends on how long the input was high for so if the button was on for 10s the light will stop on after the button goes low for 10s
but the delay rime can only go upto 30s
i hope ive worded that a bit better

thanks all for your help
217  Using Arduino / Project Guidance / Re: timing within a loop on: May 14, 2012, 09:53:36 am
one more thing, (just to make it a bit simpler, base this on button examle) when the button pin goes low there would be a delay of upto 30seconds before the LED goes low, but if the button is only on for a period of 10seconds then the LED will only stay on after the button goes low for 10seconds. hope you understand what i mean there

also the delay time needs to be without a delay like the example blink without delay.

thanks joe
218  Using Arduino / Project Guidance / Re: timing within a loop on: May 14, 2012, 09:24:46 am
hi there think i have figured it now

Code:

int ledPin =  13;    // LED connected to digital pin 13
int button = 2;      // button pin

int count = 0;       // Our blink counter

// The setup() method runs once, when the sketch starts

void setup()   {               
  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);
  pinMode(button, INPUT); 
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                   
{
  if (digitalRead(button)== HIGH)  // buttin when high
  {
  if (count < 1) {
    digitalWrite(ledPin, HIGH);   // set the LED on
    delay(1000);                  // wait for a second
    digitalWrite(ledPin, LOW);    // set the LED off
    delay(1000);                   // wait for a second
   
    count++;  // add one (1) to our count
  }
  }
  else {
    if(count == 1) count =0;       // resetting the count
  }
}
219  Using Arduino / Project Guidance / Re: timing within a loop on: May 13, 2012, 08:51:40 am
ok
do we have an example of this?
220  Using Arduino / Project Guidance / Re: timing within a loop on: May 13, 2012, 08:00:20 am
hi yes i would have put it in setup but i need it to do it the first revolution everytime when the heat button goes high. obviously it resets when it goes low
221  Using Arduino / Project Guidance / Re: timing within a loop on: May 13, 2012, 03:22:37 am
hope this is beter
Code:

const int heatbutton     = 2 ;
const int ignition_fan_2 = 10;
const int saleswitch     = 4 ;
const int solenoid       = 12;
const int photo_pressure = 3 ;
const int lockoutled     = 8 ;
const int heatbutton_feed= 5 ;
const int fan            = 9 ;
const int relay230_24    = 11;
const int ionisation_in  = 7 ;
int ionisation     = 5 ;   

void setup()
{
  pinMode(heatbutton,       INPUT );   
  pinMode(ignition_fan_2,   OUTPUT);
  pinMode(saleswitch,       INPUT );
  pinMode(solenoid,         OUTPUT);
  pinMode(photo_pressure,   INPUT );
  pinMode(lockoutled,       OUTPUT);
  pinMode(heatbutton_feed,  OUTPUT);
  pinMode(fan,              OUTPUT);
  pinMode(relay230_24,      OUTPUT);
  pinMode(ionisation_in,    INPUT );
  //-------------------------------------------
  digitalWrite(heatbutton_feed, HIGH);
}

void loop() {
  int val = analogRead(ionisation);
  //--------------------------------------------------------------------

  if (digitalRead(heatbutton)==        HIGH) {
    //                                                  ** from here need's to just run once **

    if (digitalRead(ionisation_in)==   HIGH) {       // if ionisation swith HIGH
      if (val >900)  {
        digitalWrite(solenoid,              LOW);                                       
        digitalWrite(lockoutled,            HIGH);
        digitalWrite(heatbutton_feed,       LOW);
      }
    }   
    else {
      if (digitalRead(photo_pressure)==     HIGH) {         // if photo swith HIGH
        digitalWrite(lockoutled,            HIGH);                                       
        digitalWrite(solenoid,              LOW);
        digitalWrite(heatbutton_feed,       LOW);
      }
    }
    digitalWrite(relay230_24,            HIGH);        // 230V out put to ignition
    digitalWrite(fan,                    HIGH);
    digitalWrite(ignition_fan_2,         HIGH);
    delay(2000);       
    //                                                           ** to this point **

    //---------------------------------------------------------------------
    if (digitalRead(saleswitch)==HIGH) {           // sale switch if HIGH
      digitalWrite(solenoid,     HIGH);
    }
    //---------------------------------------------------------------------
    else {                                            // sale switch if LOW
      digitalWrite(lockoutled,      HIGH);
      digitalWrite(ignition_fan_2,  LOW);
      digitalWrite(solenoid,        LOW);
      digitalWrite(fan,             LOW);
      digitalWrite(heatbutton_feed, LOW);
    }
    //---------------------------------------------------------------------
    delay(2000);
    if (digitalRead(ionisation_in)== HIGH) {
      if (val >900)                         {            // ionisation if LOW
        digitalWrite(solenoid,        LOW);
        digitalWrite(ignition_fan_2,  LOW);
        digitalWrite(lockoutled,      HIGH);
        digitalWrite(heatbutton_feed, LOW);
        digitalWrite(heatbutton_feed, LOW);
      }
    }

    if (digitalRead(photo_pressure)==LOW)  {          // photo if LOW
      digitalWrite(solenoid,         LOW);
      digitalWrite(ignition_fan_2,   LOW);
      digitalWrite(lockoutled,       HIGH);
      digitalWrite(heatbutton_feed,  LOW);
    }
    //---------------------------------------------------------------------
    else {
      digitalWrite(ignition_fan_2, LOW);
    }
    //---------------------------------------------------------------------
  }
  else {                                          // switching off
    digitalWrite(solenoid,       LOW);
    digitalWrite(ignition_fan_2, LOW);
    digitalWrite(relay230_24,    LOW);
    delay(30000);
    digitalWrite(fan,            LOW);
  }
  //---------------------------------------------------------------------

}
222  Using Arduino / Project Guidance / Re: timing within a loop on: May 12, 2012, 03:22:55 pm
i have written in the code which bit i want to run once
 
Code:
void loop() {
     int val = analogRead(ionisation);
   //--------------------------------------------------------------------
   
    if (digitalRead(heatbutton)==      HIGH) {
    //                                                                                                         ** from here need's to just run once **
    if (digitalRead(ionisation_in)==   HIGH) {       // if ionisation swith HIGH
    if (val >900)  {
    digitalWrite(solenoid,              LOW);                                       
   digitalWrite(lockoutled,             HIGH);
  digitalWrite(heatbutton_feed,         LOW);
   }
 }   
  else {
  if (digitalRead(photo_pressure)==     HIGH) {         // if photo swith HIGH
   digitalWrite(lockoutled,             HIGH);                                       
   digitalWrite(solenoid,               LOW);
  digitalWrite(heatbutton_feed,         LOW);
   }
 }
  digitalWrite(relay230_24,            HIGH);        // 230V out put to ignition
  digitalWrite(fan,                    HIGH);
  digitalWrite(ignition_fan_2,         HIGH);
  delay(2000);       
    //                                                                                                         ** to this point **
  //---------------------------------------------------------------------
  if (digitalRead(saleswitch)==HIGH) {           // sale switch if HIGH
  digitalWrite(solenoid,       HIGH); }
  //---------------------------------------------------------------------
  else {                                            // sale switch if LOW
   digitalWrite(lockoutled,      HIGH);
   digitalWrite(ignition_fan_2,  LOW);
   digitalWrite(solenoid,        LOW);
   digitalWrite(fan,             LOW);
   digitalWrite(heatbutton_feed, LOW);
   }
  //---------------------------------------------------------------------
  delay(2000);
   if (digitalRead(ionisation_in)== HIGH) {
  if (val >900)                         {            // ionisation if LOW
   digitalWrite(solenoid,          LOW);
   digitalWrite(ignition_fan_2,    LOW);
   digitalWrite(lockoutled,        HIGH);
   digitalWrite(heatbutton_feed,   LOW);
   digitalWrite(heatbutton_feed,   LOW);
   }
 }
   
   if (digitalRead(photo_pressure)==LOW)  {          // photo if LOW
     digitalWrite(solenoid,         LOW);
   digitalWrite(ignition_fan_2,    LOW);
   digitalWrite(lockoutled,        HIGH);
   digitalWrite(heatbutton_feed,   LOW);
   }
   //---------------------------------------------------------------------
   else {
       digitalWrite(ignition_fan_2, LOW); }
   //---------------------------------------------------------------------
   }
   else {                                          // switching off
        digitalWrite(solenoid,       LOW);
        digitalWrite(ignition_fan_2, LOW);
         digitalWrite(relay230_24,   LOW);
        delay(30000);
        digitalWrite(fan,            LOW); }
   //---------------------------------------------------------------------
   
       }
223  Using Arduino / Project Guidance / timing within a loop on: May 12, 2012, 02:42:58 pm
hi there
i have a code that runs when an input is high which obviously runs over and over continously as long as the button is high but the first half of the code i only want to run once but obviously if the button goes low then high again it will reset and will obviously do the first half again once?

thanks Joe
224  Using Arduino / Programming Questions / Re: ionisiation? on: March 05, 2012, 12:08:00 pm
ok thanks
what do we call high voltage?
225  Using Arduino / Programming Questions / Re: ionisiation? on: March 03, 2012, 10:32:35 am
how would i wire it for high voltage?
diagram
Pages: 1 ... 13 14 [15] 16 17 ... 20