floats and selenoid valves for a newbie

hey all ...

maybe someone can help me with this.

ive wrote as much info as I can, perhaps someone can point me in the right direction.

im new to this programming world

/***********************************************************************************

* * Wiring * Pin 2 - Float Switch A51 * Pin 3 - Float Switch A99 * Pin 4 - Float Switch B51 * Pin 5 - Float Switch B99 * Pin 6 - selenoid valve 1 * Pin 7 - selenoid valve 1 * Pin 8 - selenoid valve 1 * Pin 9 - selenoid valve 1 * Pin 10 - LED * * Control Behavior: * liquid comes in through a manifold under vaccum to 2 tanks (A,B) * Vaccum is pulled in both tanks trhough selenoid valves 1 and 2 * tanks are emptied via gravity flap once pressure equalise with the atmosphere. * pressure is equalised using selenoid valve 3 and 4 * tanks are fed liquid through check valves from the manifold * tanks have 2 float switches each one at 51% capacity one at 99% capacity * * behaviour is as follow: as tank A reaches 51% liquid level vacuum is started to be pulled from tank B * tanks get liquid equally until tank A reaches 99% * tank A no longuer has vacuum pulled and equalise pressure, releasing liquid * tank B keeps filling up until 51% then vaccuum is pulled on tank A * * External Resources * ***********************************************************************************/ //define the input/output pins

define A51FLOAT_SWITCH_PIN 2

define A99FLOAT_SWITCH_PIN 3

define B51FLOAT_SWITCH_PIN 4

define B99FLOAT_SWITCH_PIN 5

define Valve_1_PIN 6

define Valve_2_PIN 7

define Valve_3_PIN 8

define Valve_4_PIN 9

define LED_PIN 10

//setup runs once void setup() { //setup input pins for float switch //Too use a bare switch with no external pullup resistor, set the pin mode to INPUT_PULLUP to use internal pull resistors. This will invert the standard high/low behavior pinMode(A51FLOAT_SWITCH_PIN, INPUT_PULLUP); pinMode(A99FLOAT_SWITCH_PIN, INPUT_PULLUP); pinMode(B51FLOAT_SWITCH_PIN, INPUT_PULLUP); pinMode(B99FLOAT_SWITCH_PIN, INPUT_PULLUP);

//setup output pins for relays/pumping station and LED board pinMode(Valve_1_PIN, OUTPUT); pinMode(Valve_2_PIN, OUTPUT); pinMode(Valve_3_PIN, OUTPUT); pinMode(Valve_4_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT);

}

//loop() runs indefinitely void loop() {

//check to see the state of the float switches. These states are assuming the pin is using an internal pullup resistor. // LOW corresdponds to the float switch being at its lowest point (i.e. low water) //empty if(digitalRead(A51FLOAT_SWITCH_PIN) == LOW) if(digitalRead(A99FLOAT_SWITCH_PIN) == LOW) if(digitalRead(B51FLOAT_SWITCH_PIN) == LOW) if(digitalRead(B99FLOAT_SWITCH_PIN) == LOW)

digitalWrite(Valve_1_PIN, HIGH); //open vacuum to A digitalWrite(Valve_2_PIN, LOW); //open vacuum to B digitalWrite(Valve_3_PIN, LOW); //purge A digitalWrite(Valve_2_PIN, LOW); //purge B digitalWrite(LED_PIN, HIGH); //turn on the LED } { //check to see the state of the float switches. These states are assuming the pin is using an internal pullup resistor. // LOW corresdponds to the float switch being at its lowest point (i.e. low water) //a51 if(digitalRead(A51FLOAT_SWITCH_PIN) == HIGH) if(digitalRead(A99FLOAT_SWITCH_PIN) == LOW) if(digitalRead(B51FLOAT_SWITCH_PIN) == LOW) if(digitalRead(B99FLOAT_SWITCH_PIN) == LOW)

digitalWrite(Valve_1_PIN, HIGH); //open vacuum to A digitalWrite(Valve_2_PIN, HIGH); //open vacuum to B digitalWrite(Valve_3_PIN, LOW); //purge A digitalWrite(Valve_2_PIN, LOW); //purge B digitalWrite(LED_PIN, HIGH); //turn on the LED } { //check to see the state of the float switches. These states are assuming the pin is using an internal pullup resistor. // LOW corresdponds to the float switch being at its lowest point (i.e. low water) //a99 if(digitalRead(A51FLOAT_SWITCH_PIN) == HIGH) if(digitalRead(A99FLOAT_SWITCH_PIN) == HIGH) if(digitalRead(B51FLOAT_SWITCH_PIN) == LOW) if(digitalRead(B99FLOAT_SWITCH_PIN) == LOW)

digitalWrite(Valve_1_PIN, LOW); //open vacuum to A digitalWrite(Valve_2_PIN, HIGH); //open vacuum to B digitalWrite(Valve_3_PIN, HIGH); //purge A digitalWrite(Valve_2_PIN, LOW); //purge B digitalWrite(LED_PIN, HIGH); //turn on the LED } { //check to see the state of the float switches. These states are assuming the pin is using an internal pullup resistor. // LOW corresdponds to the float switch being at its lowest point (i.e. low water) //b51 if(digitalRead(A51FLOAT_SWITCH_PIN) == LOW) if(digitalRead(A99FLOAT_SWITCH_PIN) == LOW) if(digitalRead(B51FLOAT_SWITCH_PIN) == HIGH) if(digitalRead(B99FLOAT_SWITCH_PIN) == LOW)

digitalWrite(Valve_1_PIN, HIGH); //open vacuum to A digitalWrite(Valve_2_PIN, HIGH); //open vacuum to B digitalWrite(Valve_3_PIN, LOW); //purge A digitalWrite(Valve_2_PIN, LOW); //purge B digitalWrite(LED_PIN, HIGH); //turn on the LED } { //check to see the state of the float switches. These states are assuming the pin is using an internal pullup resistor. // LOW corresdponds to the float switch being at its lowest point (i.e. low water) //b99 if(digitalRead(A51FLOAT_SWITCH_PIN) == LOW) if(digitalRead(A99FLOAT_SWITCH_PIN) == LOW) if(digitalRead(B51FLOAT_SWITCH_PIN) == HIGH) if(digitalRead(B99FLOAT_SWITCH_PIN) == HIGH)

digitalWrite(Valve_1_PIN, HIGH); //open vacuum to A digitalWrite(Valve_2_PIN, LOW); //open vacuum to B digitalWrite(Valve_3_PIN, LOW); //purge A digitalWrite(Valve_2_PIN, HIGH); //purge B digitalWrite(LED_PIN, HIGH); //turn on the LED } { //check to see the state of the float switches. These states are assuming the pin is using an internal pullup resistor. // LOW corresdponds to the float switch being at its lowest point (i.e. low water) if(digitalRead(A51FLOAT_SWITCH_PIN) == LOW) if(digitalRead(A99FLOAT_SWITCH_PIN) == LOW) if(digitalRead(B51FLOAT_SWITCH_PIN) == HIGH) if(digitalRead(B99FLOAT_SWITCH_PIN) == LOW)

digitalWrite(Valve_1_PIN, HIGH); //open vacuum to A digitalWrite(Valve_2_PIN, HIGH); //open vacuum to B digitalWrite(Valve_3_PIN, LOW); //purge A digitalWrite(Valve_2_PIN, LOW); //purge B digitalWrite(LED_PIN, HIGH); //turn on the LED } //otherwise the float switch is HIGH // HIGH corresponds to the float switch being at its higest point (i.e. full water) else { digitalWrite(LED_PIN, LOW); //turn off the LED }

I get the following errors

Arduino: 1.6.13 (Windows 7), Board: "Arduino/Genuino Uno"

sumpPumpDemo:81: error: expected unqualified-id before '{' token

{

^

sumpPumpDemo:96: error: expected unqualified-id before '{' token

{

^

sumpPumpDemo:111: error: expected unqualified-id before '{' token

{

^

sumpPumpDemo:126: error: expected unqualified-id before '{' token

{

^

sumpPumpDemo:141: error: expected unqualified-id before '{' token

{

^

exit status 1 expected unqualified-id before '{' token

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Hi, In the IDE goto Edit>Preferences and set "Show line numbers". Then replace your code so we can see what lines these errors relate to.

I don't have time to attest to the logic side of your code right now, but I will say your syntax is well and truly off.

It appears you are trying to use curly brackets to section off pieces of code in ways the language never intended. I will suggest reading up on that first.

What you are looking for is:

loop()
{                                      //this curly bracket opens the code to run the loop subroutine

  if(condition == desired)
  {                                    //this curly bracket opens the code to be run if the "if" statement is true
    do stuff;                        //your code here
   }                                   //this curly bracket closes the code run for if the "if" statement is true
}                                      //this curly bracket closes the code to run in the loop subroutine

In order to do multiple "if"s, you can either nest them or combine their statements.

/********NESTED*************/

loop()
{
  if(1 == 1)
  {
    if(2 == 2)
    {
     do stuff here;
    }
  }
}
/*********COMBINED STATEMENTS********/

loop()
{
  if(1 == 1 && 2 == 2)
  {
  do stuff here;
  }
}

Duplicate. Thread locked