Help with solenoid valves and pump project

Heu guys.
I am very very new to the world of Arduino.
I am doing a project this summers where I want to operate 16 solenoid valves along with a pump.
I want 4 of the solenoid valves to work simultaneously while the others remain closed and so on.
My code doesn't seem to work. I have attached a copy of my code. Please tell me what I am doing wrong?

@scooby96, please do not cross-post. Other thread removed.

Post code, not pictures of code

Sorry. Here is the code. Please do help.

int solenoidPin = new int[16]; //This is the output pin on the Arduino we are using
for(int i=0;i<16;i++)
{
solenoidPin
=0;*
}
void setup() {

  • for(int i=0;i<16;i++)*
  • {*
    _ pinMode(solenoidPin*, OUTPUT); //Sets the pin as an output*_
    * }*
    }
    void loop() {
    * for(int i=0;i<16;i+=4)*
    * {*

_ digitalWrite(solenoidPin*, HIGH);
digitalWrite(solenoidPin[i+1], HIGH);
digitalWrite(solenoidPin[i+2], HIGH);
digitalWrite(solenoidPin[i+3], HIGH);
delay(1000);
digitalWrite(solenoidPin, LOW);
digitalWrite(solenoidPin[i+1], LOW);
digitalWrite(solenoidPin[i+2], LOW);
digitalWrite(solenoidPin[i+3], LOW);
delay(1000); *_

* }*

}

I have been searching the net for hours for a code that would help me operate multiple solenoid valves simultaneously. Is there any link or resource which I can refer to? please help.

So we are trying to build an automated air sampling system. We have 16 bags which would be used to collect the air samples. We want 4 of the bags to be filled together with the help of solenoid valves while the rest of the bags remain closed. Once the first four bags are filled we want the next 4 to get filled and the process continues till all bags are filled up. We would be using a 12v pump as well which would remain open till all bags are filled. I am also using a relay board.

I am using an Arduino Mega for the above task.

You can not connect a solenoid directly to an Arduino pin, you need some sort of driver like a transistor.

Before you get fancy just use the simple LED blink program on one pin to switch one solenoid. Get that working first.

I have already tried the LED blink program on one pin to switch one solenoid. I have a relay board which i will be using to run the solenoids. I just need to know the programming.

What part of STOP CROSS-POSTING do you not understand?

Where have i cross posted?

Delta_G:
Did it work? Then you have the code to make one of the solenoid work. Making four of them work means doing that same business on three more pins. What's hard about it?

For a beginner it is hard. So if you could help withe code it would be of great help.

I am using this code.

int solenoidPin = 4; //This is the output pin on the Arduino we are using

void setup() {
// put your setup code here, to run once:
pinMode(solenoidPin, OUTPUT); //Sets the pin as an output
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(solenoidPin, HIGH); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin, LOW); //Switch Solenoid OFF
delay(1000); //Wait 1 Second
}