Controling Solenoid valves

Hi all,

Using the attached circuit, I control 3 different solenoid valves (12v). The sketch does what I want it to do and everything is ok. However, when I have the valves plugged in and I power the Arduino (UNO-R3) with 12v input, the valves go on for about some miliseconds. If I have the circuit already powered up and then I plugg in the valves, there is no problem.
Is that normal behaviour or I have done something wrong?

Thanks in advance!

The diodes must return to the same +12V rail as the valves are powered from, this is
essential as the high speed inductive spikes will only be quenched properly if the
path between the valve windings and the diode is short and direct.

In fact the diodes should be mounted on the valves themselves ideally. If your valves are
designed for 12V DC they might already have diodes built-in - if so the terminals will be
marked with polarity.

Thanks for your input.

I've tried to see if there is a polarity label somewhere, but I don't find any. The valves I'm using are like this one: http://www.eventile.de/2-2-Wege-Magnetventil/6mm-Anschluss/12V-DC--o--STECKER--SCHW--180.html
They are indeed designed for DC 12V

The other issue you have is that the Arduino bootloader drives digital pin 13 when it is looking to see whether you want to upload a new sketch. So don't use pin 13 to drive anything critical - such as your solenoid valves.

dc42:
The other issue you have is that the Arduino bootloader drives digital pin 13 when it is looking to see whether you want to upload a new sketch. So don't use pin 13 to drive anything critical - such as your solenoid valves.

Yeah, I saw that a little late, I'm afraid. I believe that's the main issue I've been observing. When I was building this project I ran out of pins... I think I will use pin #13 for a button instead.