Pages: 1 [2]   Go Down
Author Topic: code issues  (Read 1198 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 285
Posts: 25632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A really good idea, before you post code, is to hit ctrl-t in the IDE, to sort out the indentation.
It makes it easier to read.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:

/*                       PRIVA GAS / OIL CONTROL
 
 */
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 map1_or2       = 6 ;
const int relay230_24    = 11;
const int ionisation_in  = 7 ;
const int ventbutton     = 13;
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(map1_or2,         INPUT );
  pinMode(relay230_24,      OUTPUT);
  pinMode(ionisation_in,    INPUT );
  pinMode(ventbutton,       INPUT );
  Serial.begin(9600);
  //-------------------------------------------
  digitalWrite(heatbutton_feed, HIGH);
  //--------------------------------------------------------
}

void loop()       
{     
  //--------------------------------------------------------
  //                            ******  Serial  ******
  Serial.print("** PRIVA CONTROL  **");
  void newLine();

  Serial.print("Pilot or ign       :");
  Serial.println(digitalRead(map1_or2));

  Serial.print("Ionisation swith input  :");
  Serial.println(digitalRead(ionisation_in));

  Serial.print("photo or pressure       :");
  Serial.println(digitalRead(photo_pressure));

  Serial.print("sales switch           :");
  Serial.println(digitalRead(saleswitch));

  Serial.print("Ionisation              :");
  Serial.println(analogRead(ionisation));


  delay(1000);


  //              ******  map 1 or 2  ******
  if (digitalRead(map1_or2)==   LOW)  {
    //------------------------------------------------------------------------------------
    //                           ******  gaz map-1  ******

    if (digitalRead(heatbutton)==     HIGH) {                 // Heat button
      digitalWrite(fan,               HIGH);
      delay(4000);
      //-------------------------------------------------------------------------------------
      if (digitalRead(saleswitch)==     HIGH) {               // sale switch if HIGH
        digitalWrite(solenoid,          HIGH);
        delay(5000);
        digitalWrite(ignition_fan_2,    HIGH);
      }
      //-------------------------------------------------------------------------------------
      else {                                                  // sale switch if LOW
        delay(10);
        digitalWrite(solenoid,          LOW);
        digitalWrite(fan,               LOW);
        void LED2();
        digitalWrite(heatbutton_feed,   LOW);
      }
      //--------------------------------------------------------------------------------------
      if (digitalRead(photo_pressure)== LOW)  {                // pressure if LOW
        delay(10);
        digitalWrite(solenoid,          LOW);
        void LED1();
        digitalWrite(fan,               LOW);
        digitalWrite(heatbutton_feed,   LOW);
      }
    }
    else {                                                //when heat button is LOW
      digitalWrite(solenoid,           LOW);
      digitalWrite(ignition_fan_2,     LOW);

      if (digitalRead(photo_pressure)==  LOW) {              //   low gaz pressure
        digitalWrite(solenoid,           LOW);
        digitalWrite(heatbutton_feed,    LOW);
        void LED1();                                         //   Lock out LED
      }
      if (digitalRead(ventbutton)== HIGH) {
        digitalWrite(fan,           HIGH);
      }
      else {
        digitalWrite(fan,           LOW);
      }
    }
  }

  //--------------------------------------------------------------------------------------
  //                       ******  oil map-2  ******
  else {
    //--------------------------------------------------------------------

    if (digitalRead(heatbutton)==            HIGH) {
      delay(10);    //debounce
      if (!DoneInitialization)
      {                                                 
        if (digitalRead(ionisation_in)==     HIGH) {          // if ionisation swith HIGH
          int val = analogRead(ionisation);
          if (val <900) {                                       
            void LED3();
            digitalWrite(heatbutton_feed,    LOW);
            return;
          }
          if (digitalRead(photo_pressure)==  LOW)
          {                                                   // if clixon swith LOW
            delay(10);
            void LED1();         
            digitalWrite(heatbutton_feed,    LOW);
            return;
          }
        }   
        else {                         
          if (digitalRead(photo_pressure)==  HIGH)
          {                                                   // if photo swith HIGH
            delay(10);
            void LED1();         
            digitalWrite(heatbutton_feed,    LOW);
            return;
          }
        }
        digitalWrite(fan,                    HIGH);
        delay(4000);       

        //---------------------------------------------------------------------
        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(solenoid,        LOW);
        digitalWrite(fan,             LOW);
        void LED2();
        digitalWrite(heatbutton_feed, LOW);
      }
      //---------------------------------------------------------------------
      delay(3000);
      if (digitalRead(ionisation_in)==  HIGH)            // if ionisation swith HIGH
      {
        int val = analogRead(ionisation);
        if (val >900) {                                  // ionisation if LOW   
          digitalWrite(solenoid,        LOW);
          digitalWrite(heatbutton_feed, LOW);
          void LED3();
        }
      }

      if (digitalRead(photo_pressure)==LOW)  {           // photo if LOW
        delay(10);
        digitalWrite(solenoid,         LOW);
        digitalWrite(heatbutton_feed,  LOW);
        void LED1();
      }
      //---------------------------------------------------------------------
      else {
        digitalWrite(ignition_fan_2,   LOW);
      }
    }
    //---------------------------------------------------------------------
    else {                                          // switching off
      digitalWrite(solenoid,       LOW);
      digitalWrite(ignition_fan_2, LOW);
      DoneInitialization=false;                    // resetting the count
      delay(1000);
      digitalWrite(relay230_24,     LOW);
      if (digitalRead(ventbutton)== LOW) {
        delay(5000);
        digitalWrite(fan,           LOW);
      }
      //--------------------------------------------------------
      //                ******  vent button  ******
      if (digitalRead(heatbutton)==    LOW) {
        if (digitalRead(ventbutton)== HIGH) {
          digitalWrite(fan,           HIGH);
        }
        else {
          digitalWrite(fan,           LOW);
        }
      }
    }
  }
  //--------------------------------------------------
  //         ****** LED blink LOCK OUTS ******
  //--------------------------------------------------
  void LED1();
  {                 // gaz: HIGH/LOW pressure     oil: photo LOW  or auxhillary
    digitalWrite(lockoutled,HIGH);
    delay(1000);
    digitalWrite(lockoutled,LOW);
    delay(1000);
  }


  void LED2();
  {                  // sale switch if LOW
    digitalWrite(lockoutled,HIGH);
    delay(500);
    digitalWrite(lockoutled,LOW);
    delay(500);
    digitalWrite(lockoutled,HIGH);
    delay(500);
    digitalWrite(lockoutled,LOW);
    delay(1000);
  }


  void LED3();
  {                  // ionisations
    digitalWrite(lockoutled,HIGH);
    delay(500);
    digitalWrite(lockoutled,LOW);
    delay(500);
    digitalWrite(lockoutled,HIGH);
    delay(500);
    digitalWrite(lockoutled,LOW);
    delay(500);
    digitalWrite(lockoutled,HIGH);
    delay(500);
    digitalWrite(lockoutled,LOW);
    delay(1000);
  }

}



Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 285
Posts: 25632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There seems to be a closing brace after the closing brace of LED3.
Which has an excess semicolon.
That's not right.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes as we send we was going to try it all in the loop
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 285
Posts: 25632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can't define functions inside other functions
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your original version with separate oil and gaz functions was nicer, although IMHO those functions were too long for comfort too. Throwing them into loop instead isn't going to help - you need to debug it. So repeating advice that you've so far ignored, use a bunch of Serial.print statements to show you what code is getting executed.
Logged

Pages: 1 [2]   Go Up
Jump to: