Multiple Solenoids and how not to blow anyhing up?

Ok, i'm trying to hook up 9 mini solenoids to an arduino duemilanove, so that I can control each one from the arduino, by doing something like this:

The solenoids I'm planning to use are these:

The MOSFETs are these:

I was wondering if anyone could advise me what diodes to use?

And also, and most importantly, if this is just going to create a massive failure in the way I've described the circuit?

Huge thanks from another electronics newbie! any help at all would be amazing!

I've taken a look here already:

Yes that looks fine. Any diode should do typically a rectifier diode 1N4001 is used here. R1 I would put at 3K3 rather than 1K but it is not critical. Some people would recommend a 10K from the base to ground as well.

Finally I would put a large capacitor across the 12V supply, something in excess of 220uF just to take out some of the current surge.

You say mosfets but you have drawn transistors? They are not logic level FETs but at 5V gate voltage they are in the 1R8 to 5R3 turn on range so while they are on they are not hard on. Look for a FET that says 'Logic level FTE' for the best results but these will do for what you want them for.

I think just about any diode will do, the 1N4004 is a common as dirt general purpose diode, I'm sure that will do.

BTW, You've drawn transistors not FETs.

From memory the 2n7000 is good for about 200mA so it should be OK with that solenoid.

And also, and most importantly, if this is just going to create a massive failure in the way I've described the circuit?

Not that I can see. Looks OK.


A final note: if you do use the 2N7000 instead of a transistor (not a bad idea) then the 10k resistor from gate to source is highly recommended else the gate will float when the Arduino is unpowered or in reset. That is undesirable.

-- The Quick Shield: breakout all 28 pins to quick-connect terminals

Thank you so much Mike! You're a legend.

Ok, 3.3K resistors instead of 1K, a 10K resistor from base to ground.

I'm not entirely sure of the difference between a regular transistor, a field effect transistor and a MOSFET, do they have different symbols? I Can't find a "logic level" FET on RS that isn't a MOSFET, but you say the MOSFET I've found previously should be ok?

When you say I need a 220uF or greater capacitor across the 12V supply, does that mean the capacitor going from the 12V to the ground, something like this? Also, what voltage should the capacitor have? I've found one that has a spec of 16V, would that be OK?

So, a shopping list: 1N4001 Diode here:

Capacitor here:

Sorry for all the newbie questions!

Ah, ok, so 10K resistors from pin to MOSFET if using MOSFETs not Transistors, not 3.3K? Otherwise all fine?

Thanks everyone :D

do they have different symbols

Yes they are totally different devices.


does that mean the capacitor going from the 12V to the ground,

Yes just like you drew.

Also, what voltage should the capacitor have

The voltage rating of the capacitor should be greater than the voltage you are going to use it at. As a rule 80% is a good rating so for use at 12V then 16V or greater rating is what you want.

If you are using a FET then 1K is fine but put an additional resistor from the gate to ground just to keep things turned off when the 12V is connected but the arduino power is not.

A mosfet is a particular kind of fet. Instead of flowing current from base to emitter to turn it on (like a bipolar transistor, which is what you have drawn), you apply a voltage between the gate and the source (which is connected to ground for an n-channel mosfet in the circuit you've drawn). You really, really want to make sure that you apply enough voltage to the mosfet to turn it all the way on; otherwise, it behaves like a voltage controlled resistor and gets really hot. The pull-down resistor on the gate will turn it solidly off when unpowered. A 16V cap is a little lower voltage than I'd use, but will probably work well enough.

Eep! Ok, I see, well, the application is to bring up "shapes" made out of a combination of the solenoids poking up through a surface. It shouldn't be more than 1 operation per second, but i guess while the solenoids are energized they form the display, so the MOSFET would be allowing current through all the time while the display was being shown (instead of in quick striking pulses like the glokenspiel) if this is a problem, should I use a different FET instead of the 2N7000?

The MOSFET will not be dissipating 1.2W. It is the solenoid dissipating 1.2W. This means at 12V the solenoid is allowing about 100mA of current to flow (12V * 0.1A --> 1.2W).

At 100mA the on-resistance of the 2N7000 (about 5ohms worst case) means the 2N7000 should dissipate 0.1*0.1*5=50mW.

It will be safe.

-- Need a custom shield? Let us design and build one for you.

Thank you everyone, i can get those parts ordered now! Wish me luck :D

Hi everyone, I have a quick question, I've set up the circuit as described for just one solenoid using a 12V 1.25A power supply. It seems to work in principle, except when I set the pin high the amount the solenoid moves is so tiny that it can't be seen, just felt as a light pressure. Does anyone know whet i might be doing wrong? I'm sure it's something really simple I'm missing...

Here's my code

 for solenoids

 moves a solenoid and lights an led when a button is pressed
 The circuit:
 * LED attached from pin 13 to ground 
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 * see pdf cirrcuit for solenoids, attached to pin 8 in this example

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin
const int solPin1 =  8;      // the number of the solenoid pin
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize serial communications (for debugging only):
  pinMode(ledPin, OUTPUT);         // initialize the LED pin as an output
  pinMode(solPin1, OUTPUT);         // initialize the solenoid pin as an output
  pinMode(buttonPin, INPUT);         // initialize the pushbutton pin as an input:

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {         
    digitalWrite(ledPin, HIGH); //turn on LED
    digitalWrite(solPin1, HIGH);      //tell solenoid to turn on
    Serial.println("button pressed down");
  else {
    digitalWrite(ledPin, LOW);   // turn LED off
    digitalWrite(solPin1, LOW);      //tell solenoid to turn off   
    Serial.println("button NOT pressed down"); 

Huge thanks for your help everyone!

Ok, when the wire that was going to pin 8 of the arduino is connected to the 12V power supply instead it causes the solenoid to become pulled in fully, fixed in place, instead of being free to move. Is that what should happen? What I want is for the solenoid to push up and stay there while the button is pressed.

I have a multimeter yes.

Thanks so much!

Ok I'm sorry, i attached the lead that was in pin 8 to 5V and nothing happened at all. All the grounds are attached together. I thought 5V wasn't enough to drive the solenoid?

Ah! I'm sorry, I'm an idiot, I'd not turned on the 12V supply, connecting the lead that was in pin 8 to 5V does cause the solenoid to pull in, i'm mistaken. When the button is pressed in the original configuration the solenoid is pulled in also.

I think I might have the wrong sort of solenoid. I bought a push action solenoid here:

I thought this meant that it would "push" upwards like a pointing finger when powered. Looks like it just pulls the bar all the way inside. Or am i just not understanding?

...perhaps if i turn it upside down and use the skinny end...

Ok, i'm officially overcoming a serious case of noob-itis. Apologies for my stupid questions, It all seems to be working, I'd just never used solenoids before!

Thank you so much for your help! I hadn't realized how the solenoids worked. Now I need to get the whole thing soldered up and into a rig. I was amazed the solenoid actually worked with my circuit first time, even though i thought it didn't!