void loop()
{
int value;
for(value = 0 ; value <= 255; value+=5)
{
digitalWrite(M1,HIGH);
digitalWrite(M2,HIGH);
analogWrite(E1, value); //PWM Speed Control
analogWrite(E2, value); //PWM Speed Control
delay(30);
}
}
If you are using the code sample from the link it is not appropriate for a solonoid valve.
Crazylgels suggestion is OK.
OR
Use a power N-MOSFET.