Control a Solenoid with an Arduino (Tutorial)

  Рет қаралды 211,250

Matt Inglot

Matt Inglot

Күн бұрын

My complete guide to using your Arduino to control a solenoid! Building a custom pinball machine sent me down the rabbit hole of learning how to control solenoids with a micro controller. It turns out there are a few gotchas to watch out for.
FINAL SCHEMATIC:
www.dropbox.com/s/wffsfemuwia...
PARTS USED:
- Solenoid: JF-0826B (12V/2A) - amzn.to/3e9T8fy
- Solenoid: F0464A (24V/2A)
- Arduino Uno: amzn.to/2RAV7BW
- Screw Terminals: amzn.to/3x3gDQ4
- Logic Level MOSFET: FQP30N06L or IRLZ44NPBF
- Flyback Diode: 1N4007
See schematic for resistor values
As an Amazon Associate I earn from qualifying purchases.
ERRATA
Schematic has been adjusted compared to the video to address the following:
Circuit 2 shows a 10K resistor between the push button and MOSFET gate (not to be confused with the 10K pulldown resistor from gate to ground). Yet the third circuit does not show a resistor on the gate (placed between the Arduino pin and the gate). On further research, a resistor in the ~150ohm range appears ideal between Arduino pin and the gate.
Reasoning: when a MOSFET is switched on, the gate acts as a capacitor and allows a large momentary inrush of current In theory this could damage the power source. As with everything electronics, there is more to this story, but that should get you going.
DISCLAIMER:
For educational purposes only and not meant to replace proper training. Working with electricity and tools can be dangerous. Use the knowledge in this video at your own risk.
If you see mistakes please leave comments (preferably with a source) so I can make corrections if needed.
#solenoid #arduino #electronics

Пікірлер: 388
@bradleylovej
@bradleylovej Жыл бұрын
This is a really good video. Very clearly explained, in a nice, even manner. At first I didn't think I wanted to watch a 20 minute video, but once it started, I didn't think twice about it
@MattInglot
@MattInglot Жыл бұрын
Thanks!
@Mr69er1000
@Mr69er1000 2 жыл бұрын
You might not be an electrical engineer but you helped me in my EE senior design :) Thanks a lot for the thorough walkthrough and multiple revisions, as well as having links to the parts used!
@MattInglot
@MattInglot 2 жыл бұрын
That makes me really happy to hear! Good work getting through your project! I'm glad the video helped.
@gonzalezrubiocarlosandresj8130
@gonzalezrubiocarlosandresj8130 Жыл бұрын
You helped me in my BME senior design. Thanks for the thorough walkthrough and multiple revisions and tips. Excellent content, greetings from México!
@MattInglot
@MattInglot Жыл бұрын
That's really wonderful to hear! Nice work!
@razTAH-p6h
@razTAH-p6h Жыл бұрын
This is what I've been looking for! Best video on KZfaq for using solenoids with Arduino. Thanks a lot!!
@wheelseo938
@wheelseo938 2 жыл бұрын
It was a pleasure to watch this video and to listen to your clear explanations. Thank you!
@shvideo1
@shvideo1 2 жыл бұрын
Very educational and practical video considering that solenoids are also used in locks. Thank you for the detailed explanation and the schematic. This is a great electronics project.
@MattInglot
@MattInglot 2 жыл бұрын
Thank you so much!
@RobinsonTechnologies
@RobinsonTechnologies 2 жыл бұрын
Appreciate you showing the simpler circuit (before the mosfet was added), most people skip that kind of stuff but it's very useful for understanding things!
@MattInglot
@MattInglot 2 жыл бұрын
Glad it helped!
@anandjoshi8554
@anandjoshi8554 Жыл бұрын
@@MattInglot i am using three power supply 5, 12 and 24 vdc, should i connect all 0 ve /grd together, to be given to the diffrent powered dc outputs ?
@anandjoshi8554
@anandjoshi8554 Жыл бұрын
@@MattInglot can i use Adriuno in place of costly PLC to manage a DIY project comprising of 4 dc outputs and 3 ac outputs (0.2 - 9 amp via ssr) and 7 dc inputs....using relay module ? (my plc ladder has 58 rungs in total )
@MattInglot
@MattInglot Жыл бұрын
@@anandjoshi8554 Yes absolutely. If using multiple supplies in the same circuit, tie the grounds together.
@MattInglot
@MattInglot Жыл бұрын
@@anandjoshi8554 Yep. I'm not experienced with PLCs but Arduino can certainly control all this stuff. Just keep in mind that PLCs are very different than Arduino, again not experienced with them but my understanding is they are built to withstand harsh environments and be super reliable and all that.
@softshore
@softshore 5 жыл бұрын
Wow, I always see someone using a relay for this and honestly never thought of using a MOSFET. It was a great video, you deserve more subscribers.
@MattInglot
@MattInglot 5 жыл бұрын
Thanks so much I really appreciate it! More vids are coming soon too.
@233kosta
@233kosta 4 жыл бұрын
When I bought my little pack of mosfets, I worked out that a relay that could handle the same current (70A) would probably cost a good bit more than the 10 I bought put together. Relays, of course, tend to have higher voltage ratings and I hear they're not too fond of PWM switching roles... 😁
@jorgemercent2995
@jorgemercent2995 3 жыл бұрын
Thank you very much Matt. Appreciate you going through everything step by step.
@MattInglot
@MattInglot 3 жыл бұрын
Thank you :)
@sastrydasigi7010
@sastrydasigi7010 5 жыл бұрын
Hi Matt, it's a fascinating project... and you are an amazing teacher!
@MattInglot
@MattInglot 4 жыл бұрын
Thank you!
@oliverward6344
@oliverward6344 4 жыл бұрын
Hi!, just thought I'd say what a good video it is! you explain the circuit clearly and simply, not like some people that just rush through it without properly explaining. :)
@MattInglot
@MattInglot 4 жыл бұрын
Thank you kindly! It feels risky putting up a 20 minute explanation to something that others explain in 10 so this is reassuring to hear.
@oliviaadel765
@oliviaadel765 2 жыл бұрын
My GOSH! your presentation skills are Awesome.. Please don't ever stop what you're doing
@MattInglot
@MattInglot 2 жыл бұрын
Thank you so much!
@David-fq6ly
@David-fq6ly 3 ай бұрын
Thanks, this was really helpful!! Also probably the best intro on any KZfaq video I've seen!
@MattInglot
@MattInglot 3 ай бұрын
Thank you!
@seanocansey2956
@seanocansey2956 5 жыл бұрын
Optocouplers are your best friend if going from digital electronics to power electronics, I'd look them 👍🏾🙂 Edit: they basically completely isolate the input signals from the output. It does that by converting electrical signals to light, then back to electrical signals. This means no voltage ot current spikes will damage low power electronics Note: With opto-couplers, you *don't* want to connect grounds or power sources to each other, otherwise you'll defeat the purpose of the chip.
@shitheadjohnson2797
@shitheadjohnson2797 Жыл бұрын
optocouples dont take much amps, because the optic part of them burns out. but they are cool.
@SebVEVO
@SebVEVO 7 ай бұрын
Thx, great tutorial that highlights important aspects that I might have missed otherwise.
@andrewhowlett4792
@andrewhowlett4792 16 күн бұрын
Hi Matt, thanks for this video. This helped me a lot with my newest project.
@istvanagoston7137
@istvanagoston7137 Жыл бұрын
Finally, my issue is solved with the solenoid, all thanks to you! You got a new subscriber and lots of respect
@MattInglot
@MattInglot Жыл бұрын
Nicely done!
@t.n.1056
@t.n.1056 Ай бұрын
I have to be honest man: this video is one of the best videos for describing a project for arduino! I really really have to say: Thank you man!
@express375
@express375 3 жыл бұрын
The most complete and easy to get explination I've seen,thanks
@MattInglot
@MattInglot 3 жыл бұрын
Thanks!
@karamazov7193
@karamazov7193 3 жыл бұрын
Great job Matt, clear explanations, did not felt like a 20 min video.
@MattInglot
@MattInglot 3 жыл бұрын
Thanks that's really appreciated!
@dominick3579
@dominick3579 4 жыл бұрын
This really helped me understand how apply the use of a transistor!
@MattInglot
@MattInglot 4 жыл бұрын
Awesome, I'm so glad to hear :D
@MatthewCarlsen
@MatthewCarlsen 4 жыл бұрын
Hey Matt great video!! I found this video through search and I’m looking to build a project using a sollinoid. I saw that you have a fairly new channel so I thought I’d help you out with a comment, like, and a new subscriber! Great job man!
@MattInglot
@MattInglot 4 жыл бұрын
Thanks so much that's really awesome of you. What is your project?
@wanna312
@wanna312 3 ай бұрын
Awesome easy to follow tutorial. And great humor at the very beginning😂😂
@jullianhoff849
@jullianhoff849 4 жыл бұрын
Your explanations are so clear. Thank you.
@MattInglot
@MattInglot 4 жыл бұрын
Thanks so much, glad it helped!
@rogueart7706
@rogueart7706 2 жыл бұрын
To overcome the limited duty cycle of a solenoid just double the voltage capacity of the solenoid. In other words, on a 12 volt supply just use a 24 volt solenoid. As a builder of solenoid engines this video is great. Thanks a bunch.
@MattInglot
@MattInglot 2 жыл бұрын
Thanks and great tip!
@davidpp9999
@davidpp9999 4 жыл бұрын
Great explanation, really liked the video
@MattInglot
@MattInglot 4 жыл бұрын
Thanks so much!
@joshpatterson2773
@joshpatterson2773 4 жыл бұрын
This video was insanely helpful. Thanks so much!
@MattInglot
@MattInglot 4 жыл бұрын
Very glad to hear!
@silverspoon987
@silverspoon987 Жыл бұрын
You're a hero. Got my valve working now. Thank you
@FirthFabrications
@FirthFabrications 3 жыл бұрын
This is exactly the video I needed for my project. Thanks!! 🙏
@MattInglot
@MattInglot 3 жыл бұрын
Awesome! What are you building?
@FirthFabrications
@FirthFabrications 3 жыл бұрын
@@MattInglot On my channel I recently built a flip top tool cart. I am trying to automate the flipping of the cart. I am going to use solenoids as the locking mechanism.
@MattInglot
@MattInglot 3 жыл бұрын
@@FirthFabrications Cool! That sounds like a great use for one.
@xyloidify
@xyloidify 5 жыл бұрын
I liked the video, thank you for sharing your research. Subscribed.
@MattInglot
@MattInglot 5 жыл бұрын
Thank you!
@haywardhaunter2620
@haywardhaunter2620 2 жыл бұрын
Excellent presentation. Be careful using a solderless breadboard for this: Many are rated to 0.5 Amps, though there are some high quality ones rated to 2 Amps. As Sean Ocansey said in the comments, the next step is to use an optoisolator. Since you won't have to connect the grounds together, your sensitive Arduino electronics will be better protected from the spikey and noisy electromechanical circuit. Many of the solenoids in a pinball machine are switched on only briefly, but flippers are trickier. Since the player may hold the flipper up for an arbitrary amount of time, there's a risk of exceeding the duty cycle of the solenoid. So many (all?) pinball machines initially power the flipper at its full voltage when the player first presses the button, but then switches to a lower voltage if the player holds the button in. The full voltage gives the flipper the power to bat the ball, and the lower voltage is enough to keep the flipper up. At the lower voltage, the solenoid will generate less heat, so it can be kept on without exceeding the duty cycle.
@MattInglot
@MattInglot 2 жыл бұрын
Lots of great points thanks!
@mhansl
@mhansl 4 жыл бұрын
Very good explanation and demo of the circuit. Should mention that the MOSFET is a type of transistor.
@MattInglot
@MattInglot 4 жыл бұрын
Yes good point! Thank you!
@chuckpatten7855
@chuckpatten7855 5 жыл бұрын
One concept that you might like to know about is opto isolation. This is where you don't want to commingle your power supplies which can keep you from blowing up your controller due to large switching currents. Use an optoisolator. Your micro turns on a LED which then turns on a light sensitive transistor in the separate circuit.
@MattInglot
@MattInglot 5 жыл бұрын
100% That's a good approach too.
@chuckpatten7855
@chuckpatten7855 4 жыл бұрын
@dylans voice it depends upon what you are thinking of in terms of switching currents . If you mean external circuits that are not connected to the circuit and power supply then bypassing the power lines and shielding the board within a metal enclosure will probably work. If the anticipated noise is due to induced ground currents then the way to proceed is to insure that there are no non isolated connections to the power to the external controls and that the ground for the controller is only connected to the power supply directly.
@chuckpatten7855
@chuckpatten7855 4 жыл бұрын
@dylans voice plenty fast for this application. Look at the data sheet for the one you choose for performance data.
@edfl4913
@edfl4913 Жыл бұрын
I got the schematic. THANK YOU!!!
@No1sonuk
@No1sonuk 4 жыл бұрын
The 10K from Gate to ground pulls the Gate down after the drive signal is released. if you use a resistor on the drive side, you get a potential divider. If that resistor is 10K, the Gate gets only half the drive voltage. Using 100 ohms puts the level much higher, making it turn on better. If the gate signal is being driven by a logic output, such as the Arduino, you may not _need_ either of those resistors, but it's a good idea to have them for "failsafe".
@MattInglot
@MattInglot 4 жыл бұрын
That's a great point.
@noahvanrossum1075
@noahvanrossum1075 3 жыл бұрын
Thanks for the clear explanation! Would it be possible to connect the Arduino as well as the solenoid to the same power supply (in parallel), such as a simple battery holder? Because that way the voltage comes straight from the source itself, instead of going through the Arduino first, while still connecting both grounds.
@MattInglot
@MattInglot 3 жыл бұрын
I don't see why not. Give it a shot and if you run into issues go down the troubleshooting rabbit hole until you figure it out. One thing I'd wonder about is voltage drop on the battery when firing the solenoid, and needing to throw some capacitors in to counteract that. I may play around with this one day with my scope hooked up, just haven't had a chance to do it. If I do it I'll make a video. But for sure play around, have fun, see what you learn.
@mdd0204
@mdd0204 4 жыл бұрын
Great explanation !
@awjaaa
@awjaaa Жыл бұрын
Excellent video, man.
@MattInglot
@MattInglot Жыл бұрын
Thank you!
@joshuapatterson5095
@joshuapatterson5095 4 жыл бұрын
Great tutorial mate.
@MattInglot
@MattInglot 4 жыл бұрын
Thanks so much Joshua!
@nolesdennhardt8986
@nolesdennhardt8986 3 ай бұрын
Awesome video! Thanks for the details. I am currently trying to learn how to wire and code something similar, except I want to reduce the current at end of stroke using the PWM outputs on my control board. Ill look around your channel! I can hopefully find something because it's a head scratcher for me using a 2 pin solenoid. Basically just hoping to hold the solenoid (and flipper bat) in its extended position without burning out the coil. Thanks again!
@lebronsdad9554
@lebronsdad9554 3 жыл бұрын
Great, informative video! I plan on doing something similar with a solenoid controlled air valve. Since it wasn't shown on screen, what did you end up using for your 12V power supply? A 12V wall plug or just a series of batteries?
@MattInglot
@MattInglot 3 жыл бұрын
I'm powering it off the wall plug. You can use batteries of course.
@willyangabrigo1174
@willyangabrigo1174 3 жыл бұрын
What solenoid shoild i use, planing to make a gear shifting mechanism for my motorcycle
@teodordicu361
@teodordicu361 2 жыл бұрын
Hello! I have a question.. I got my hands on a IRF520 module, can it do the work for me if I add a diode?
@twomeyconsulting
@twomeyconsulting 4 жыл бұрын
Extremely helpful, thank you!!
@MattInglot
@MattInglot 4 жыл бұрын
Thank you I am glad it helped :D
@Malbu226
@Malbu226 2 жыл бұрын
Quick question if I wanted to run a solenoid that would ring a bell like a fire alarm how would I do that? Also being able to change the Hz frequency up and down to adjust the bell hits slower or faster. A variable power supply would be used so the voltage can be increased to make the bell hits harder and louder.
@MattInglot
@MattInglot 2 жыл бұрын
What a great question. You got me so curious about this that I looked up how those old school fire alarm bells work and you're not far off with your idea. I managed to find this article: www.aplustopper.com/working-of-an-electric-bell/ It looks like these types of bells already use electromagnets to function (remember, that's really all a solenoid is...), and there are different ways of making that mechanism work. What I love about the one in that article is that it naturally creates the ringing by interrupting the circuit when it the hammer hits the bell, which allows it to retract back, which closes the circuit and activates the electromagnet, which brings the hammer back to the bell, and so on. You could very easily swing a hammer with a solenoid in a similar way. Just have the hammer pivot on something, so that when the solenoid pulls down the hammer swings and hits the bell. You could then vary the frequency with how often you pull down the solenoid (eg. fire it once a second, twice a second, etc). You are correct that you can control the strength of the hit by varying the voltage, however you don't need a variable power supply. If you're using an Arduino like in my example, just make sure you connect the solenoid to a PWM pin, then use Arduino PWM functionality to simulate the voltage change (eg. 50% PWM would effectively give you half the voltage). Note that you won't necessarily have a linear correlation between PWM frequency and volume so if you're building a volume knob or something you will have to experiment with how to map the PWM frequency to the desired volume. Keep in mind that the purpose built fire bell mechanisms like the one I linked have a very small amount of travel, which allows them to ring at a (relatively) high frequency. If you buy an off the shelf solenoid, like the ones on Amazon, those things take a (relatively) long time to plunge back up after plunging down so that will limit the frequency. That should really be it. Be sure to watch the video because that Arduino circuit is exactly what you need, and the rest is just building the mechanical piece. Good luck!
@attilanemeth8215
@attilanemeth8215 4 жыл бұрын
Begginer here. Will i need these mosfet and diode and stuff if i controll a relay module with the arduino and the relay just lets of prevents the electricity into the solenoid?
@MattInglot
@MattInglot 4 жыл бұрын
You don't need a mosfet because the relay will act as the switch instead of the mosfet. And if you are using a relay module then it takes care of some of the details of using relays correctly (like a protection across the relay since it's also an inductor). I would definitely still put a diode on the solenoid (make sure the polarity is reversed like discussed in the video, else you will short out your circuit!) to protect anything the solenoid is hooked up on the same circuit with including your power supply.
@edfl4913
@edfl4913 Жыл бұрын
Love the video!!!
@gonorthoffgrid1786
@gonorthoffgrid1786 4 жыл бұрын
So im using a ardino to fire a solinoid 15 ms on 30ms off repetivly at the comand of a button Qestion is is it benificial to use a diode in my solinoid circuit off the mos fet and is it still desirable to ground out the mosfet gate.
@MattInglot
@MattInglot 4 жыл бұрын
Yes. You'll probably get away without the grounded gate if you have the Arduino hooked up to it, but I don't see a reason not to ground it. If you leave the diode out, you will potentially fry your Arduino.
@Lee-At-Green-Pheonix-Rc
@Lee-At-Green-Pheonix-Rc 3 жыл бұрын
I'm looking at these to activate a pull pin on a rc 1/10 winch can I just hook up the positive to a switch turn on stays pulled in until switch is turned off then springs back then opersite way wind winch in 🤔
@TangodownNZ
@TangodownNZ Жыл бұрын
Please. What diode should I use for a 24 volt 2 amp solenoid? Thank you
@benjidabull
@benjidabull 3 жыл бұрын
you deserve more subs my man
@MattInglot
@MattInglot 3 жыл бұрын
Thanks I appreciate it :)
@julienh.5057
@julienh.5057 2 жыл бұрын
Thanks for sharing! Humbly asking: how comes you fit a 3A fuse and a solenoid that will draw 2A on a breadboard that is probably not rated for those values? (At least you didnt mention the specs).
@MattInglot
@MattInglot 2 жыл бұрын
Thanks. You want the fuse to blow as a protection measure if the load on the circuit is higher than expected, which most likely means something has shorted out and will draw all the current the power supply can put out (until the supply's own fuse blows). So if we assume that solenoid was indeed 2A, you want something higher. I eyeballed 3A because it gives the margin of error, but should still blow if the circuit has a serious fault (again almost certainly a short because something got plugged in wrong or loose). The goal is protect the power supply and possibly prevent a fire if you're using a supply that can put out way more current than you need (think those DIY ATX ones without current limiting). That said, fuses are complicated: kzfaq.info/get/bejne/ja1hZNWHyLOzno0.html As for the breadboard: it was there to demo only, yes I should have pointed it out. Basically you might not get full power from your solenoid if you use a breadboard because of the high resistance it has.
@nithinkumardatti5846
@nithinkumardatti5846 3 жыл бұрын
Thank you so much for the video. Can we control pneumatic solenoid only with arduino and relay
@diaverde09
@diaverde09 4 жыл бұрын
Very helpful information. Thank you.
@MattInglot
@MattInglot 4 жыл бұрын
Thank you!
@danmeuse496
@danmeuse496 2 жыл бұрын
hi, i bought some IRFP260Ns before watching this vid, and im having trouble getting the program to work. Im starting to worry that it might not be logic level capable, but i dont know how to find out for sure
@5amJones69
@5amJones69 Ай бұрын
This is great. Do you have any video's on how to vary the velocity of the solenoid?
@MattInglot
@MattInglot 28 күн бұрын
You can use PWM to change the strength of the magnet which would in turn affect the velocity of the plunger, and maybe more importantly, how much force it hits things with (in the case of an application like a pinball machine flipper). Don't expect any fine control over this though! If you want that, you should really be looking at a stepper motor instead. Solenoids are great when you need that little bit of very sudden (and strong) movement. But you frequently see people trying to use them in places where a stepper is the better solution (and vice versa). Why controlling velocity of a solenoid is a funny thing: The acceleration changes with how much of the plunger is within the magnetic coil vs outside of it, because then more of the plunger has a magnet acting on it, and you get exponentially more force. Acceleration determines the change in velocity. So if the acceleration gets faster and faster as more of the plunger enter the magnetic coil, the velocity also gets faster and faster as the plunger enter. Put in simpler terms, when the solenoid activates, the plunger is initially moving very slowly (relatively speaking) and by the time it plunges all the way, it's moving extremely fast. It's not a linear speed. You can see force charts for some solenoids in their datasheet. Don't think you can see acceleration or velocity normally, but it's going to be a similar idea. All the action happens towards the end of the plunge.
@ericmwangi4484
@ericmwangi4484 3 жыл бұрын
hi.. i want to control 3 solenoid valves at the same time and connect the same to the water level indicator please help
@MicaseHD
@MicaseHD 2 жыл бұрын
I want to make A mini jackhammer out of a push pull solenoid. I don't know how to make it work like a jackhammer?? like 'Push and pull' is one cycle like a jackhammer. I have been trying to find out how for like 4 days now. is there a little pcb board that can do this or control it?
@thomasryan4697
@thomasryan4697 4 жыл бұрын
How does one determine the size of the resistors and the type of.diode to use,. Can this design incorporate a break beam sensor
@No1sonuk
@No1sonuk 4 жыл бұрын
The resistor numbers aren't particularly critical in this case. About 10K from Gate to ground pulls the Gate down after the drive signal is released, and the 100 ohm from signal to Gate is just a little protection. If the gate signal is being driven by a logic output, you may not need either of those resistors.
@jeanetiennette5742
@jeanetiennette5742 Жыл бұрын
Hello Matt, your video is awesome. Thank you for sharing. One thing, with this set up, do you think we can actually control the speed (force) of the solenoid?
@MattInglot
@MattInglot Жыл бұрын
Thanks Jean. You absolutely can, that's actually one of the benefits of this setup (as opposed to using a relay). Look up PWM - Pulse Width Modulation. This is what modern pinball machines do to allow the operator to adjust the strength of the flippers for example.
@JohnDoew-hz8qt
@JohnDoew-hz8qt 7 ай бұрын
Excellent and clear spoken diagrams explanations, without anoying music, easy to understand, many thanks for posting `! PLease explain how to retain the solenoid for 3 seconds ? Now its acting more like pulse latching
@AslamYusof
@AslamYusof 4 жыл бұрын
thank you, Mat. very helpful. subscribed
@MattInglot
@MattInglot 4 жыл бұрын
Thank you! :)
@petaca39
@petaca39 2 жыл бұрын
good video I ask you a question is it possible to control an electromagnet through an arduino but using pulses instead of the classic turn off and turn on as if it were a led
@MattInglot
@MattInglot 2 жыл бұрын
Thanks. Yes you can build the exact circuit I show and just make sure to hook up the mosfet gate to a PWM enabled pin on the Arduino. Then you can use PWM to control the strength of the electromagnet.
@Dg-zj6jo
@Dg-zj6jo 2 жыл бұрын
Hi there I need 12v small one that pushes when I turn power off
@chrisferraro5462
@chrisferraro5462 2 жыл бұрын
Hi Matt, great video! Quick question -- What is the voltage across breadboard 26e (or simply row 26) and row 21 when no voltage is supplied to the gate on the Mosfet (output pin 8 removed)? I have more or less replicated what you have but am finding that when 0V is supplied to the Gate, the voltage on the load is still around 2V… when I supply 3V to the Gate, the voltage on the load is 12V as expected. Trying to understand why there is always 2V even when the Arduino is not supplying any output. Was expecting the voltage to be 0 or close to it. Thanks!
@MattInglot
@MattInglot 2 жыл бұрын
Hey Chris, it's been a while since I've played with this circuit but taking a quick look at my schematic again (which you can download in the video description by the way, may help to make sure everything is wired up right), I'm pretty sure it's because the load isn't part of a complete circuit when the Gate is pulled down to 0V. So you're getting some potential differences but they should be meaningless. If you try to connect your meter in series with the load and measure current you can verify that nothing is happening. All that said, if you're using two power supplies like I did in my project, make sure the GNDs of the supplies are tied together so that they agree on what 0V is. Or you will get all sorts of interesting measurements and very possibly damage the Arduino. Good luck!
@dulshanariyarathne2253
@dulshanariyarathne2253 Жыл бұрын
Can these solanoid used to make a vibration? Like keep on for 20ms and off for 20ms. Repeat it continuously
@MattInglot
@MattInglot Жыл бұрын
Technically yes, but uhh what are we vibrating here? When I think "vibration" I think either a speaker, or a I think of a DC motor with an uncentered mass attached to it that vibrates when it spins. Solenoid will bang around until the frequency exceeds how quickly it can retract, but I'm having trouble picturing where that would be desirable.
@questort
@questort Жыл бұрын
What component would you use if you want the latch to travel a much longer distance?
@MattInglot
@MattInglot Жыл бұрын
Assuming you don't need the near-instant actuation, a stepper motor would do a great job. Or even a regular motor with the right gearing. See how smart locks work on doors.
@seanocansey2956
@seanocansey2956 5 жыл бұрын
Good vid btw, a bit of constructive criticism, I'd try to draw diagrams or Schematics to help explain what you're doing 👍🏾
@MattInglot
@MattInglot 5 жыл бұрын
Thanks Sean. Yes that's a good idea, I hope to do this at some point.
@elliot1784
@elliot1784 4 жыл бұрын
@@MattInglot If you provide the schematics i'll subscribe to your channel :D lol thanka for the video tho great stuff!
@MattInglot
@MattInglot 3 жыл бұрын
Wow this video took off more than I expected. Schematic is now in description. If I missed any detail from the video in it someone let me know ;) It's been a while!
@tswdev
@tswdev 4 жыл бұрын
Hi. I am building a controller for a airsoft gun that uses high pressure air controlled by a solenoid valve. I can get the arduino pro micro to control the valve but sometimes after i fire the arduino restarts. I am using the same 7.4v lipo to power the arduino and the solenoid. I suspect there might be a current drop during firing that starves the arduino but i dont have enough experience to know for sure neither how to solve it. Have you done this before? Have any ideas?
@MattInglot
@MattInglot 4 жыл бұрын
Never done this before, but battery not being able to handle the current sounds plausible. Check the specs. With lipos they have a rating for how quickly they can discharge. You also say that the Arduino resets *after* the solenoid has already fired. Did you remember to put the flyback diode on the solenoid? If that doesn't help, honestly I would Google or post on a place like the electronics stackexchange making sure you include your circuit diagram, and the specs of everything you are using. There's not really enough info here to troubleshoot further.
@odiliomartinez6811
@odiliomartinez6811 2 ай бұрын
hi and thank you...i'm not sure if i'm seeing this wrong, having trouble following the breadboard wiring...the flyback diode should t not be in parallel to the solenoid? also the fuse should it not be on the input rather than the output?
@MattInglot
@MattInglot 2 ай бұрын
The diode polarity should be opposite that of the solenoid, else you basically create a short (sorry I THINK that's what you are asking). As for the fuse, take a look at the schematic posted in the description. When the fuse pops, does it create an open circuit?
@74potions
@74potions 3 жыл бұрын
Hi Matt, I hope your pinball project went well! I'm about to follow this project as part of my University final year project but can't find out what the components you have used are. What's the name of the blue piece that takes the power supply? And how have you exposed 2 wires from the power supply also? I have a 12v power lead with the regular power jack which without changes cannot be used to power the breadboard. The solenoid I am using is also 12v.
@MattInglot
@MattInglot 3 жыл бұрын
If you Google "screw terminal block" you should be able to find them. Or if your power supply already has a different connector (sounds like a barrel jack most likely), then you could get the female barrel jack connector for your breadboard and use that. That will actually be a more reliable connection if you're trying to build something more permanent.
@superliegebeest544
@superliegebeest544 2 жыл бұрын
Great video. I dont know anything aboud adruinos but can the nano control 4of these and a ultrasonic sensor?
@MattInglot
@MattInglot 2 жыл бұрын
You need an IO pin for each thing you wish to control. Additionally not each pin is created equal, for example only some pins on the Nano have PWM which you might want for controlling the solenoid. So to answer any such question you start by finding a "pinout" diagram for your target controller, such as this one for the nano: www.circuitstoday.com/wp-content/uploads/2018/02/Arduino-Nano-Pin-Description-952x1024.jpg Then you confirm whether there are enough pins that have the capabilities that you need (hint: in your case it's very much yes)
@jakewatermelon8576
@jakewatermelon8576 4 жыл бұрын
Great video, thank you for this. I do have a question though, would you be able to replace the button with a lever? I need the solenoid to be held down, without manually holding the button down.
@MattInglot
@MattInglot 4 жыл бұрын
Hey Jake you can use any switch you want in whatever shape you want. There are also mechanical button switches out there that toggle, so you press it and it stays on until you press it again. Or if you plan to use this with the Arduino like the last example, then you have full freedom to decide how long the solenoid stays on. The only catch is that if you are going this route, you want a solenoid rated for continuous duty. Intermittent and pulse solenoids are not meant to have current go through them for very long at a time. You haven't specified your intended application, but you may also wish to look into latching solenoids and into servos in case one of these parts suits your project better.
@jakewatermelon8576
@jakewatermelon8576 4 жыл бұрын
@@MattInglot Thank you, I appreciate your response
@flesz__
@flesz__ 3 жыл бұрын
I have a question. I bought 12V/2A solenoid and have 8 AA batteries to provide 12V. Can I connect batteries directly to solenoid and solenoid will only pull max 2A as its designed, or will it take all the power it can causing it to overheat. Would I need to put some resistors on the batteries first or just directly 12V to solenoid would be fine?
@MattInglot
@MattInglot 3 жыл бұрын
A power source being able to supply MORE current than your load needs is not a problem. The solenoid has a certain resistance, which in turn determines how much current it will draw thanks to Ohm's law. So the load determines the current drawn, not the supply. Of course you're probably asking this because you've seen resistors being a requirement for using LEDs, because otherwise the LED WILL blow itself up very quickly. That's because diodes (including LEDs) have very little internal resistance and will happily burn themselves out immediately without a resistor to limit the current. So if you hook up your LED without a resistor, you have a load with very little resistance and hence it will draw a lot of current (again Ohm's law comes into the picture), and the LED will blow up. Your problem might be that 2A is a lot of current for a AA battery. You can actually look up datasheets for batteries and see what that looks like, but 2A seems like a lot. At the very least I would expect it to discharge quickly. THAT said, if you are only pulsing the solenoid for short periods, it may be totally fine and you may still get adequate performance.
@SuperJatoba
@SuperJatoba 3 жыл бұрын
muito obrigado,estou construindo uma micro puncionadeira cnc,este video me ajudou muito,obrigado por esta aula
@venugopalswamy5121
@venugopalswamy5121 2 жыл бұрын
Can we make a solenoid which can lift around 5kg with the same pull push solenoid but with stroke length of 150mm
@MattInglot
@MattInglot 2 жыл бұрын
Of course you can. Whether it's practical or not is a different question. It's going to need to be a pretty big and powerful solenoid, especially if you're hooking the weight directly to the plunger because you've got no mechanical advantage. I have no idea what your application is, but there's a good chance you would be better served by something else like a servo motor which will be a fraction of the cost and size to lift 5kg (at the disadvantage of taking a lot longer to lift the load).
@_crazytechz
@_crazytechz 3 жыл бұрын
Awesome mate , Great video and clear explanation I am new subscriber Your support is highly valued thanks
@Sara-dp1rq
@Sara-dp1rq 3 жыл бұрын
Good evening, i whatched the video and i found it very usefull. I recently bought a solenoid valve for my arduino project. I connect it with a diode and a mosfet (IRF520). The power supply is 5V, coming out from arduino. The mosfet is working (led on of the mosfet) but the solenoid is freezed. You have an idea of the reason? Thank you very much
@MattInglot
@MattInglot 3 жыл бұрын
If everything is hooked up correctly and you can measure 5V on the Arduino pin when it's on, , but you can't measure any voltage to the solenoid, I would double check the datasheet of your mosfet and make sure it's logic level (ie can be turned on by 5V or less). Your problem sounds a lot like that might be what's wrong.
@KaiLuckey
@KaiLuckey 4 жыл бұрын
If I forgo the fuse (I don't have one) and use an npn transistor instead of the mosfet, will this circuit still work?
@MattInglot
@MattInglot 4 жыл бұрын
Good questions. The fuse is there to protect the other components in the circuit in the case of something shorting out (and possibly your power supply if it doesn't have its own protection). I wouldn't leave it unsupervised without a fuse, but if you're watching over it then it's really up to you. If you don't have a mosfet handy (you can get cheap versions of these things off ebay or aliexpress if you're just tinkering), then my next choice would be a relay since they typically are built to handle lots of current and a component you are also likely to have lying around (and just lookup how to use them). Regarding the suitability of your NPN transistor, it depends on the transistor and how much current the solenoid you are using draws, those would be the critical pieces of information. This can all be found and verified by checking the datasheets for your components. For example if I guess you have the 2n222a that's a staple in so many electronics books, I can google 2n222a datasheet I will find www.jameco.com/Jameco/Products/ProdDS/787536.pdf And there I will see that they are intending this transistor for applications that require up to 500ma, and we are given no indications of how much they can handle for brief periods of time. That's unlikely to be a great choice, but knowing these parameters, and that NPN transistors are cheaper than gummy bears, you could experiment with a lower power solenoid and see what happens. If you go this through route then you will need to make sure you learn how to use BJTs because they operate differently. A good article on this stuff: www.ermicro.com/blog/?p=423
@BaranKaynak0
@BaranKaynak0 4 жыл бұрын
What about voltage drop on selenoid power source? How can we avoid low voltage for other parts sharing the same power source?
@MattInglot
@MattInglot 4 жыл бұрын
Hey Baran I overlooked this comment. One answer is to do what I did in the video and use two different power supplies (with their grounds connected), specifically to avoid various issues with inductive loads. That's a common technique for DIY pinball machines for example. Otherwise the short answer is "capacitors", long answer is post your schematic and relevant details, preferably on an EE forum. Unfortunately filtering power is not something I've spent enough time on to feel confident that I'm giving you good advice.
@muhammadabraar8396
@muhammadabraar8396 2 жыл бұрын
Hello sir, I am curious about how you obtain the power supply 12V. Did you use transformer to step down the voltage? Thank you 😊
@MattInglot
@MattInglot 2 жыл бұрын
Just a 12V power adapter. Those black bricks that you can buy off Amazon for example. I did not build my own if that's what your asking.
@Traderhood
@Traderhood 5 жыл бұрын
Excellent!!
@adityakulkarni4154
@adityakulkarni4154 4 жыл бұрын
Sir , by using magnetic plunger , current will generate in coil by cutting magnetic flux in coil so, is it possible to charge 3.7 V Li-Po battery by using bridge circuit and voltage regulator (7805) ?
@MattInglot
@MattInglot 4 жыл бұрын
I've never tried to build such a circuit so I can't really speak to the specifics, but if you move that magnet inside the coil rapidly enough, you will generate some amount of current. Check out how the different mechanical flashlights work, it's all this same general principle: en.wikipedia.org/wiki/Mechanically_powered_flashlight Also be careful with Li-Po batteries.
@FERNANDOMATIASDOSSANTOSDONASCI
@FERNANDOMATIASDOSSANTOSDONASCI Жыл бұрын
Hi. Would it be possible to use a TBJ instead of MOSFET as switch in this case?
@MattInglot
@MattInglot Жыл бұрын
Assuming you meant to write BJT. Yes you could, assuming you are using a BJT that is rated for your load and you build an appropriate circuit. You should google the differences between BJTs and MOSFETs though. You may come to the conclusion that you'd rather use the mosfet in this scenario
@Sloot786
@Sloot786 Жыл бұрын
How did you decide what resistors to use? Was it decided arbitrarily?
@mexicanwootwoot
@mexicanwootwoot Жыл бұрын
Will a 4.5 V 0.4 amp solenoid valve work in this setup with a 5 V power supply?
@MattInglot
@MattInglot Жыл бұрын
I wouldn't hesitate using this especially for a hobby purpose. If this is being used for commercial use then my answer is "check the manufacturer's datahsheet"
@dhananjayjoshi1040
@dhananjayjoshi1040 4 жыл бұрын
Its really good. I have doubt regarding this instead of giving supply to solenoid can we attach magnet to the solenoid and generate AC output ?
@MattInglot
@MattInglot 4 жыл бұрын
If you move a magnet through a coil of wire, you will induce current in that coil (the magnet must be moving). So yes, if you were to replace the plunger with a magnet and move it back and forth, you should be able to measure some current. Tonnes of sources online if you want to read about that further, such as www.electronics-tutorials.ws/electromagnetism/electromagnetic-induction.html In fact, when you cut power to the solenoid, the magnetic field collapses, and that does induce current, which is what the diode is there to protect against. It gives it somewhere to go other than your Arduino or power supply.
@dhananjayjoshi1040
@dhananjayjoshi1040 4 жыл бұрын
@@MattInglot Thank you so much sir !!
@tomandhannah7381
@tomandhannah7381 2 жыл бұрын
Hey man, I also don't know much about circuits and am planning on making my own pinball machine, I'm going to use a 320w 48v power supply. You said you was using a power supply too, I was wondering if you would be able to show that so I can see the full connections as I'm confused to where the wires that go off screen go too and where to power supply is connected too to power the solenoid, Many thanks!
@MattInglot
@MattInglot 2 жыл бұрын
If you don't know much about electronics and are building a pinball machine then the good and bad news is that you will end up learning a lot about electronics ;) Here are a couple good resources that include wiring up power supplies, I think these will be a lot more helpful a lot faster than me typing up the same info in a KZfaq comment: mjrnet.org/pinscape/BuildGuideV2/BuildGuide.php?sid=powerSupplies pinballmakers.com/wiki/index.php?title=Construction#Power_Supplies Note that Pinball wiring and electronics can be dangerous (risk of shock from mains power, risk of fire from failing electronics). You may wish to get the proper training to work on some of this stuff, or partner up with someone who knows how to do it safely. Good luck.
@brycedavis7638
@brycedavis7638 Жыл бұрын
It seems the final schematic that you posted a link to calls for two resistors but I only see one here when you are using the arduino board. Am I missing something?
@MattInglot
@MattInglot Жыл бұрын
It's explained in the errata section of the video description, but tl;dr that 150ohm resistor is recommended and something I worked out after shooting the video.
@Ghostman539
@Ghostman539 Жыл бұрын
Great video. Thank you. I’m a complete newbie to arduino, but I’m working on a project that would require the solenoid to be activated by a remote control, is that something that is possible? Thank you.
@MattInglot
@MattInglot Жыл бұрын
Absolutely! You can control a solenoid with an Arduino, and you can send signals to an Arduino via remote control, therefore you can control a solenoid via remote control. May options for this. I believe the various Arduino kits come with an IR remote. Personally I think the nrf24l01 modules are a better option, but they are a little more advanced to get working correctly. Good luck.
@Ghostman539
@Ghostman539 Жыл бұрын
@@MattInglot Thanks Matt, that’s great. I’ll look into that.
@NLGeebee
@NLGeebee 3 жыл бұрын
The one thing you need to explain about Voltages is that is is basically a -potential difference-. So 12V can be the difference between 0 and 12, but also the difference between 100 and 112. Your Arduino will be fried by 100V, so to make sure that your negative side of your 12V potential difference = 0, and not some random value, you ground everything together. Hence the name common ground.
@malikx00
@malikx00 14 күн бұрын
Hi, mine wasn't working until i removed the resistor from 1st pin of mosfet to ground. Thanks for your help.
@Kalle1854
@Kalle1854 4 жыл бұрын
Can you tell me what type of solenoid you used for the flippers? How powerful do they have to be? What ball size are you using?
@MattInglot
@MattInglot 4 жыл бұрын
I'm using the Pontiac Coil F0464A for the flippers, and a 3/4 steel ball from BC Precision Balls (CH1053). Note that I'm building a roughly 65% scale machine so these components are sized accordingly and won't work in a full-size machine. If you want to build a full-size machine, then you can buy parts specifically meant for pinball machines from the various suppliers that provide these, and build on top of a platform like P3-Roc. If you are building a smaller machine like me, be very careful selecting the ball. Pinballs need a lot of weight to be able to properly hit target and feel like pinball. Those 3/4" balls were the smallest I found that still had a proportional weight to them. Smaller balls just didn't have any heft to them.
@JMAlist
@JMAlist 4 жыл бұрын
Super helpful video! Quick question regarding Solenoids. What determines how hard they push and pull? is it Voltage rating or Amp rating?
@MattInglot
@MattInglot 4 жыл бұрын
Good question: it's not quite that simple. The strength of the coil (electromagnet) is determined partly by the current (amps) it draws, but also the number of turns of wire, how long the coil is, how close the plunger is to the coil, etc. You can google for calculators that show all this stuff. So 2 solenoids rated for the same voltage and current may have very different performance and be intended for very different uses, and the difference lies in those other variables. The situation is complicated further by the fact the force increases as you get more of the plunger inside the coil, so on datasheet you will find it's actually a graph of force vs extension of the plunger. As for relationship between voltage and current, if you look at a supplier like Digikey you will find the same solenoid model comes in 2 or 3 varieties like 2A @ 12V, 1A @ 24V, 0.5A @ 48V. All have the same force, and since P = VI, they both use the same amount of power. However since they are wound different as a result, since current is less. So *generally speaking*, as solenoid strength goes up, so does the power it draws (meaning voltage or current or both will be higher). BUT because solenoids are built with different specs in mind (including duty cycle, longevity, different plungers, etc) you can have two solenoids with identical voltage and current ratings with very different performance characteristics. If you Google around there's a tonne of info on this stuff, and yes it does get complicated and that's why I love datasheets :D
@Bianchi77
@Bianchi77 2 жыл бұрын
Nice info, thanks :)
@elliot1784
@elliot1784 4 жыл бұрын
How did you select that mosfet?.. I have a IRF520 and am wondering if it would be fine to use instead (all I have on stock). Thanks!
@MattInglot
@MattInglot 4 жыл бұрын
So notice I used two different mosfets in the example, because in the first example I was using a very typical one that needed the higher voltage to switch on, and then for the Arduino version I used a different mosfet that could switch at a lower voltage (a logic level mosfet). Very important because the Arduino GPIO pins output 5v. How do I find these components? The ultimate way is to use a site like Digikey or Mouser and use their incredible filtering tool to get the parameters you need. A shortcut is to google, which can be very useful because you'll come across components that others have used successfully, and which _likely_ are easy/cheap. So your real question is, is the IRF520 suitable? To figure that out you look at the datasheet (again Google is your friend). You find: www.vishay.com/docs/91017/91017.pdf The Gate-Source (Vgs) threshold seems to be around 4V (meaning it should start to conduct at 4V), and if you scroll further you will see a graph showing how much current the mosfet will be able to conduct depending on the Vgs. And you can see that graph starts at 4V. Soooo... you can use this mosfet, provided that you stay within the current parameters shown. Once again Google is your friend because you can easily find tonnes of discussion on how mosfets work, which ones are good to use with Arduino, etc. With the cautionary note you should always cross-reference 3 or 4 reputable sites to make sure that the information you are getting is correct. The Electronics Stack Exchange can be particularly helpful to search through because a lot of EEs frequent it.
@elliot1784
@elliot1784 4 жыл бұрын
@@MattInglot wow, what a beast. thanks :)
@haideralikhan5947
@haideralikhan5947 4 жыл бұрын
Amazing job
@MattInglot
@MattInglot 4 жыл бұрын
Thank you!
@user-fb9os7hy2y
@user-fb9os7hy2y Жыл бұрын
Excellent,very helpful for this noob..thank you
@jasonliu2310
@jasonliu2310 Жыл бұрын
Hey Matt! Super solid video but I was wondering why you ended up switching the MOSFET in your final iteration from the first one. Would your circuit still work with the original MOSFET?
@MattInglot
@MattInglot Жыл бұрын
Hey Jason I do explain that in the video. The issue is if you want to use the MOSFET with an Arduino, you need to be able to switch the gate with the 5V output of the MOSFET. So I switched in a "logic level" mosfet that is capable of being driven with a lower voltage.
@bananasplit4037
@bananasplit4037 11 ай бұрын
How can I use the circuit paired with the Arduino with a NC microswitch as a trigger, where pressing the switch runs the code to the solenoid
@bananasplit4037
@bananasplit4037 11 ай бұрын
NO( normally open
@MattInglot
@MattInglot 11 ай бұрын
​@@bananasplit4037 You should be able to find tutorials very easily on how to detect switch presses on Arduino, along with sample code. Then all you need is logic in your code that checks if the switch is pressed, then triggers the solenoid.
Arduino Lesson 4 - Solenoid control using a Transistor
10:16
DIY Tech Guy
Рет қаралды 49 М.
I tried the Cheapest Arduino Alternative (that Nobody heard of)
13:31
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
00:36
SOFIADELMONSTRO
Рет қаралды 17 МЛН
Gym belt !! 😂😂  @kauermtt
00:10
Tibo InShape
Рет қаралды 10 МЛН
Женская драка в Кызылорде
00:53
AIRAN
Рет қаралды 293 М.
Double Stacked Pizza @Lionfield @ChefRush
00:33
albert_cancook
Рет қаралды 75 МЛН
Arduino Tutorial 25: Understanding Photoresistors and Photo Detectors
36:19
MOSFETs and Transistors with Arduino
40:50
DroneBot Workshop
Рет қаралды 1 МЛН
How Wrong Is VERITASIUM? A Lamp and Power Line Story
19:17
ElectroBOOM
Рет қаралды 3,4 МЛН
How to Control a 12V Motor with Arduino: Easy Wiring & Code Examples
44:13
Hacking a weird TV censoring device
20:59
Ben Eater
Рет қаралды 3 МЛН
How To Control A Solenoid With A Raspberry Pi Using a Relay
6:15
Core Electronics
Рет қаралды 86 М.
Solenoid valves | The Beauty of Engineering
9:48
Lesics
Рет қаралды 996 М.
You can learn Arduino in 15 minutes.
16:34
Afrotechmods
Рет қаралды 9 МЛН
Todos os modelos de smartphone
0:20
Spider Slack
Рет қаралды 59 МЛН
АЙФОН 20 С ФУНКЦИЕЙ ВИДЕНИЯ ОГНЯ
0:59
КиноХост
Рет қаралды 1,1 МЛН
НЕ ПОКУПАЙ СМАРТФОН, ПОКА НЕ УЗНАЕШЬ ЭТО! Не ошибись с выбором…
15:23