controlling a solenoid with the arduino

I've searched the web and found a device to measure pressure that can be used with the arduino and a 12v water valve that is used to end the water flow by closing itself here:
What I want to know is what code should I use in order to close the solenoid and to open it?
Should it be something like:
int servo1=0;
If(volume==30) {//I will calculate the volume with the device that lets me measure the pressure with the arduino
pinMode(servo1,0);//I really don't know if this is correct, what I want to do is give a value of 0 so that the device will turn off
please correct my code!
Thanks in advance!

please correct my code!

If ==> if no capitals..

Please spent a week to read the tutorial and reference section of to get the basics of what the arduino can do and how it is done. You will find almost all the code you need there.

Do not connect a solenoid to your Arduino without The Diode more commonly understood to be needed across the coil of a relay.

Do not "try it without, see if it works". If it doesn't, you will have a fried Arduino.

"But I did try it! And my Arduino still works!"

... for now.

The Diode: