Arduino Lesson 4 - Solenoid control using a Transistor

  Рет қаралды 49,175

DIY Tech Guy

DIY Tech Guy

Күн бұрын

In this project you will learn how to connect a Solenoid Magnet to an Arduino using a transistor as a switch.

Пікірлер: 96
@renegaed
@renegaed 2 жыл бұрын
Absolutely best desciption on Arduino and solenoids. I've been confused reading tutorials but you're video was the one that made it finally click for me. Thanks very much for sharing.
@aidanpawz2205
@aidanpawz2205 2 жыл бұрын
Great video! Thank you for helping me understand how to use a solenoid. Your video was clear, quick, and understable.
@Viktorr87
@Viktorr87 2 жыл бұрын
I tried two other tutorials on youtube to no avail. This worked in an instant! Thank you!
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
Glad it helped!
@Lecandotnet
@Lecandotnet 3 жыл бұрын
Thank you for the great helps on Arduino controls solenoid.
@TheTadek2001
@TheTadek2001 Жыл бұрын
Thanks, it works! Greetings from Gdynia Maritime University!
@wesselvandenbroek4576
@wesselvandenbroek4576 2 жыл бұрын
yeaahh you helped us really well, thanks for the video man!!!
@JDKoder
@JDKoder 2 жыл бұрын
Great video. Thanks for sharing.
@TangodownNZ
@TangodownNZ Жыл бұрын
Thank you for this video. It would be great if you could do a similar one here. Its for a arcade gun recoil. After watching your video I wonder if it requires a diode. Maybe you could show us how you would make this. “The Ne555 boards are easy to hook up. They only have 3 pins. You have 5v and ground in which you'll take from the UHID. Then ground out and power out. Power out is the 3rd pin. Ground out shares the middle pin with ground in. I.e. you have two wires connected to one pin for ground. The output from the Ne555 board goes to a DC DC solid state relay. You should have one that can be triggered by as little as 3v. Connect ground out (from the ne555) to - and ne555 power output to +. At this point you should be able to activate the solid state relay by pressing the trigger or whatever button you have hooked up to the UHID (one that is set to trigger 5v on your chosen pin). Connect one of the wires from your solenoid power supply to one of the output pins on the relay. The other one goes to the solenoid. I usually have the relay connect the - and have the + from my 24v psu go directly to the solenoid. You can try it the other way if you want (or need) to. Then it's just a case of adjusting the two pots on the ne555 until the full auto feel is to your liking. The solenoid should be triggered 7-14 times per second to feel authentic kzfaq.info/get/bejne/bs2oY5OJntfLqoE.html
@kennadyintercorp5510
@kennadyintercorp5510 3 жыл бұрын
hi i have an output of 1.8v 200ms low. during this time I want to de-energise a 3v relay can I use the transistor to switch off BCS the 200ms not enough to de-energise the 3v relay
@Bianchi77
@Bianchi77 Жыл бұрын
Nice info, thanks for sharing it :)
@dumonr71
@dumonr71 3 жыл бұрын
Next question - why is the transistor tied into the negative side of the solenoid rather than the positive? Also, why is the resistor needed? I saw another video that did not use one.
@jaimecases3426
@jaimecases3426 10 ай бұрын
Question: Can I use solenoid for a water despenser that will automatically stop when a cup is about to get full?
@prasannapujar5993
@prasannapujar5993 2 жыл бұрын
can i use IRLZ34N MOSFET instead of TIP102 transistor does it also work with DC 12v solenoid valve???
@pbostjancic1
@pbostjancic1 3 жыл бұрын
Question, I would like the solenoid to open/close repeatedly every half second or so when I press a button. Can I simply add a micro switch into the circuit to the 5v +/-? As note the solenoid will be powered @ 10v using a dc power adapter via the VIN.
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
Yes, this should work, although I would prefer to control the solenoid through the code. You would need to just condition the opening and closing of the solenoid by reading the state of the button. I have a separate video that explains how to use switches and buttons with the Arduino.
@chrislewis3322
@chrislewis3322 Жыл бұрын
A year on but could you wire up a switch to turn off and on the solenoid
@mayasmahmed8471
@mayasmahmed8471 Жыл бұрын
I want to ask you if I don’t have TIP102 Transistor which other type I can use?
@marcobucci
@marcobucci Жыл бұрын
Great video! Very clear instructions. Quick semi-related question about power supply: Assuming it's the correct voltage for the solenoid I'm using ... can I hack apart my old laptop power supply by snipping off the cylindrical plug at the end (the part that would plug into the laptop)? Would that reveal the hot/ground wires needed to work with the breadboard? (I suppose I should just bite the bullet and try it myself, but I'm too nervous to ruin the power supply, lol.) Thanks again!
@jpconn1
@jpconn1 Жыл бұрын
Yes, that should work as long as the voltage is correct. The ground wire may present itself as a braided shield around the outside, but you should be able to connect it to a leaf wire using solder and some shrink tubing for insulation.
@jpconn1
@jpconn1 Жыл бұрын
Yes, that should work as long as the voltage is correct. The ground wire may present itself as a braided shield around the outside, but you should be able to connect it to a leaf wire using solder and some shrink tubing for insulation.
@jpconn1
@jpconn1 Жыл бұрын
Yes, that should work as long as the voltage is correct. The ground wire may present itself as a braided shield around the outside, but you should be able to connect it to a leaf wire using solder and some shrink tubing for insulation.
@jpconn1
@jpconn1 Жыл бұрын
Yes, that should work as long as the voltage is correct. The ground wire may present itself as a braided shield around the outside, but you should be able to connect it to a leaf wire using solder and some shrink tubing for insulation.
@jpconn1
@jpconn1 Жыл бұрын
Yes, that should work as long as the voltage is correct. The ground wire may present itself as a braided shield around the outside, but you should be able to connect it to a leaf wire using solder and some shrink tubing for insulation.
@HaidenMcGrath
@HaidenMcGrath Жыл бұрын
Great video! Quick question, why would someone use this transistor method over a 5v relay module? Thanks
@DIYTechGuyShow
@DIYTechGuyShow Жыл бұрын
For this particular application a relay would work just as well. The benefit to using a transistor is the speed at which it can be switched, the smaller form factor, the quietness of the switching operation, and the durability of the transistor over the relay due to not having any moving parts.
@lunaartemisvods8812
@lunaartemisvods8812 8 ай бұрын
I have a much larger solenoid and when plugged into a similar circuit the solenoid stays on, not caring about the transistor and the transistor rapidly heats up, is there a way around this?
@ayateleb9414
@ayateleb9414 Жыл бұрын
How do I simulate solenoid valve in proteus program?
@lasanda8885
@lasanda8885 3 жыл бұрын
Thanks ✋❤
@prasannapujar5993
@prasannapujar5993 2 жыл бұрын
Its really a great explaination! I have a question.. if i have to actuate 2 or more solenoids, connections would be the same? and if yes can i give Vin supply to other diodes too?? offcourse i will be using buck converter for regulating the voltage..
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
Sure, you can activate almost as many as you want as long as you have enough current(amps) from your power supply and enough digital pins on the Arduino to switch the transistors. I'm not sure why you would want to power any diodes from the VIN since that would be 12V. If you are talking about Light Emitting Diodes (LEDS) you would only want about 1 - 3 volts depending on the diode. These would be more easily powered by the Output pins on the Arduino. You could certainly power them from VIN, which is essentially directly from your power supply, and regulate the voltage through a buck converter and your only limitation would be the current(AMPS) supplied by your power supply.
@prasannapujar5993
@prasannapujar5993 2 жыл бұрын
@@DIYTechGuyShow ok I am clear now. thanks for ur reply 👍
@yoosefali7
@yoosefali7 2 жыл бұрын
Hello Sir .. we would like to use solenoid as shooting mechanism in small robot .. which way do you suggest to improve the return Force?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
You could use a larger solenoid and possibly some type of lever mechanism to translate the 1 inch throw of the solenoid to something 2 to 3 times greater.
@davidhollis8606
@davidhollis8606 2 жыл бұрын
How would this work if I was using a board that didn't have a Barrel Jack?. Could I just plug the V+ of the solenoid into a common 12v rail?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
Without a Barrel Jack you would need to connect your 12V power supply to the VIN Pin(Positive) and the Ground Pin. This will power the Arduino, the Arduino will convert the 12V from the Barrel Jack to 5V needed by the board. In this setup, you could also follow the instructions just as they are and hook up the solenoid and transistor through the VIN pin, but it is probably easier to just connect it directly to the power supply or 12V rail.
@raptorphotography2916
@raptorphotography2916 8 ай бұрын
Champ🏆
@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?
@DIYTechGuyShow
@DIYTechGuyShow Жыл бұрын
I have never seen a push/pull solenoid. They are usually just push or pull. The reverse direction is handled by a spring. A solenoid that pushed and pulled would actually be 2 solenoids working together to give force in either direction.
@kalenmcallister4290
@kalenmcallister4290 3 жыл бұрын
Does your heatsink on your transistor get super hot quickly during this?
@DIYTechGuyShow
@DIYTechGuyShow 3 жыл бұрын
No, not in this project. I imagine it would If I had more current running through the transistor. In cases like that, you would want to attach the tab of the transistor to a larger heatsink using some thermal compound.
@piyushsonigara5550
@piyushsonigara5550 4 ай бұрын
Sir can u please explain how do i connect 2 solenoid valves , in the same setup.
@alisameh5085
@alisameh5085 2 жыл бұрын
I want to use 5v solenoid in a control circuit of an air mattress , should i connect the solenoid directly to the ardunio ? And does the 5v solenoid even work for such circuit?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
the solenoid should be connected through a transistor, even if you have a 5v solenoid, powering from the Arduino will pull way too much current. I also doubt a 5v solenoid would be able to operate a valve. The biggest thing I have been able to do with a 5V solenoid is to ring one of those hotel bells.
@rickieyt8615
@rickieyt8615 3 ай бұрын
im confused where did you use the external power source
@Tisha378
@Tisha378 2 жыл бұрын
Question. Will it be okay if i use a 12v adapter with a 6v solenoid?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
12V would burn up the solenoid. You might be okay for short bursts, but you definitely wouldn't want to use it in an application where power is continuously applied.
@emzhang3268
@emzhang3268 3 жыл бұрын
For trinket and trinket pro, how do I power the 12 v solenoid
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
I'm not familiar with those boards, but I would assume you would tie it in directly from the power supply. I sort of cheated a bit by using the VIN pin, since I know it connected to the positive side of the barrel jack. The VIN pin is actually supposed to be used to power the board when you don't have a barrel jack or if you wanted to position the barrel jack on the outside of the case or something.
@verosanchez6087
@verosanchez6087 Жыл бұрын
Could you do this same circuit without the arduino? Just with the push button, and the other components?
@DIYTechGuyShow
@DIYTechGuyShow Жыл бұрын
Sure, you could just wire the battery to the solenoid through a pushbutton. This would allow you to simply control the solenoid manually. The Arduino allows you to programmatically control the solenoid. In this case we have a timer that activates the solenoid on a repeating basis, but it could also be used to read input from the environment and activate the solenoid based on those external inputs.
@laiskai100
@laiskai100 Жыл бұрын
IN4001 diode works with 5VDC. How to connect 230VAC solenoid? I have these controller reset effects..
@DIYTechGuyShow
@DIYTechGuyShow Жыл бұрын
I don't think you can control an AC solenoid through a transistor. A simple solution to get around this would be to use a DC relay to control the AC current. I have a separate video explaining how to do this. studio.kzfaq.infoKlxFC89gqpk/edit In that video I control a 120V lightbulb, but you could use the same design and relays to control 230V.
@lariscea
@lariscea 2 жыл бұрын
is it possible to control 2 or more solenoids with just 1 arduino, like can i add another solenoid in your demonstration?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
This shouldn't be a problem at all, the limiting factor will be your power supply and whether is can handle the current load.
@hamzi586
@hamzi586 3 жыл бұрын
Hi, iam using a solenoid valve (5v), and i want to use this method i think it should work, the only difference is the 12v power supply that i dont need it because the arduino can work with 5v, now my question is to control the valve like you did (on & of) i should do the exact thing that you did just without using the power supply is that right?
@jpconn1
@jpconn1 3 жыл бұрын
You would still need a 12 volt power supply to power the solenoid. 5volts is probably not enough. Check the specs for your solenoid to know what power it requires.
@hamzi586
@hamzi586 3 жыл бұрын
@@jpconn1 Hi Jim, i found the same circuit that been used in the video without the 12v power supply and with a 5v solenoid, the only difference is that he used another value of the diode and the transistor.. ( core-electronics.com.au/tutorials/solenoid-control-with-arduino.html)
@DIYTechGuyShow
@DIYTechGuyShow 3 жыл бұрын
@@hamzi586 For an application like this there are a bunch of different transistors and diodes that would work. The same idea applies; using a small voltage to switch a higher voltage through a transistor. If your solenoid is 5V, I'm not really sure why you need the transistor.
@Ijustwatchfunnycrap
@Ijustwatchfunnycrap 3 жыл бұрын
Could you explain how you would add a button to this setup?
@DIYTechGuyShow
@DIYTechGuyShow 3 жыл бұрын
I have a separate video that explains how to use buttons. The button video shows how to control an LED using a button. To apply it to the transistor example you would run the 5V to the transistor signal pin instead of the LED. Here is a link to the video. kzfaq.info/get/bejne/qdGFn92lq9-ukZc.html
@Ijustwatchfunnycrap
@Ijustwatchfunnycrap 3 жыл бұрын
@@DIYTechGuyShow Thank you.
@user-tt6ij8zh8b
@user-tt6ij8zh8b 8 ай бұрын
I'm confused, what is the 5v from the arduino connecting to? I see you have it going to the rail but there's nothing else connecting to the rail.??? please answer
@marciomaia4020
@marciomaia4020 6 ай бұрын
Yea I noticed that too and got me confused. It looks like an open circuit with nothing connecting to the positive on the board.
@gorgigeorgie4594
@gorgigeorgie4594 3 ай бұрын
thanks
@williamwheeler8906
@williamwheeler8906 9 ай бұрын
I'm confused, what is the 5v from the arduino connecting to? I see you have it going to the rail but there's nothing else connecting to the rail.
@Fliesana3000
@Fliesana3000 13 күн бұрын
Yes, that Cable is unnecessary... it leads to Nirvana :-)
@SunAndMoonAndEarth
@SunAndMoonAndEarth Ай бұрын
do we really have to use that transistor?
@dumonr71
@dumonr71 3 жыл бұрын
Forgive my rookie question (i'm not trained on electronics but can follow instructions). I don't have an IN4001 diode but I have some others. Can I substitute an IN4007?
@DIYTechGuyShow
@DIYTechGuyShow 3 жыл бұрын
Yes, that should work. You'll know something is wrong if the Arduino resets itself when the solenoid fires. I always add some code to blink an LED a few time during initialization, that way it is very clear that the Arduino is resetting.
@kiranbora3879
@kiranbora3879 Жыл бұрын
hello is this lock is working on Positive and Negative Pulse.
@DIYTechGuyShow
@DIYTechGuyShow Жыл бұрын
No, It is a simple solenoid that works off of the current from the power supply.
@kiranbora3879
@kiranbora3879 Жыл бұрын
@@DIYTechGuyShow ok, actually I am doing a circuit that is 12V, 2A solenoid lock control through RFID, I am doing it through the H-bridge circuit, but my output is not coming. can you help me out with this?
@sean-christianhatcher7074
@sean-christianhatcher7074 Жыл бұрын
Is it possible to do this without that bread board?
@DIYTechGuyShow
@DIYTechGuyShow Жыл бұрын
Of Course. I use a breadboard only for demonstration purposes. You could certainly wire and solder everything directly, but I would suggest soldering to a protoboard for stability and ease of installation into a project box or something.
@YashPatel-sh2ws
@YashPatel-sh2ws 3 жыл бұрын
Where to apply 12 v?
@DIYTechGuyShow
@DIYTechGuyShow 3 жыл бұрын
Good Question, not sure how I missed this in the diagram. You use a 12V power supply to power the arduino through the barrel jack. The Arduino brings this down to 5V to power the arduino logic, but still provides the full 12V power to the VIN pin on the arduino. You can see this with the purple wire that powers the Solenioid.
@jenna_junk
@jenna_junk 2 жыл бұрын
You don't need to connect a wire from the Arduino 5V to the breadboard. It's not being used at all.
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
Yes, good point. since the transistor is getting it's 5v from the pin, there is no need to power the rail.
@Barnyardbuilds286
@Barnyardbuilds286 2 жыл бұрын
Can Someone copy and paste the code. i hat copy from videos i always mess up thx
@brendanholm1666
@brendanholm1666 2 жыл бұрын
What is the rating on the transistor?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
I used a TIP102 transistor, but almost any NPN transistor could have worked for this application. The TIP102 has a max current of 8 amps which is overkill for this project, but I just happen to have a few extra ones lying around. You can see the full datasheet on the TIP102 here: www.utmel.com/components/tip102-npn-transistor-datasheet-pinout-and-application?id=799
@antmof94
@antmof94 Жыл бұрын
Wait so you said the arduino can't provide 12v then you connected 12 volts to it?
@DIYTechGuyShow
@DIYTechGuyShow Жыл бұрын
The Arduino can't output 12V through it's controlled pins. I just connected the solenoid to the 12V on the input side of the Arduino. The Arduino can accept 12V, but it steps it down to the usable 5V for the processor. The VIN Pin is connected to the barrel jack connecter prior to the step down in voltage. The reason for this is that the Arduino can be powered from either the Barrel Jack or the VIN and GND pins. By connecting my Solenoid to the VIN pin I eliminated the need to splice the incoming wire going to the barrel jack.
@c.moh8842
@c.moh8842 2 жыл бұрын
Hello Tech guy. I am trying to get this working for a college project. The code will not upload and its the xact same as your code. Any ideas?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
Will it not upload or not compile. The upload button actually does both, compiles, then uploads. If it won't compile, your issue is somewhere in your code. If it won't upload, there are a few issues that could be causing this. 1st is a bad Arduino Board, 2nd is if the wrong board is chosen under the Tools Menu, this needs to match the board you are using (Arduino Nano, Arduino Uno, etc.). The Processor chosen under the Tools menu could also be an issue, Uno should be one of the ATMega 328, and the Nano would be one of the ATmega 128. The Programmer chosen might also cause upload issues, I currently have mine set for AVRISP mkII. I hope this helps, please respond with whatever it is that fixes your issue.
@c.moh8842
@c.moh8842 2 жыл бұрын
@@DIYTechGuyShow so I went to tools your and right the board was the wrong selection. I am using a Mega 2560 so I selected that and it ran the code but the solenoid did not open (its and old solenoid I took out of an old appliance so could be siezed shut). I am also using a TIP 121 transistor. Besides that everything is identical. Thank you for your help by the way. Im a Mechanical engineerinf student and its so hard to find people who know what they are doing when it comes to arduino.
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
@@c.moh8842 well, the first thing you should check is to make sure the solenoid is functional, the easiest way to do that is to just connect it directly to the power supply and see if it activates. If it doesn’t, it is probably a bad solenoid or more likely you aren’t providing enough current. Voltage and current are very different and I this scenario you wouldn’t be able to operate a moderate sized solenoid with 8 aaa batteries. Even though you have. 12 volts, the aaa batteries won’t provide the current(amps) required. You would generally need a larger power supply the size of a laptop charger maybe. It’s tough when pulling parts from existing products to truly know the specs, but you can always hook up a larger amperage power supply, NOT VOLTAGE, just to make sure it works.
@c.moh8842
@c.moh8842 2 жыл бұрын
@@DIYTechGuyShow Yes i think you are right, its not getting the correct amount of current through the coild. Can you recommend a 12v solenoid that would work through arduino? I can get my hands on a 12v - 300mA valve. Would this work?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
Any 12V solenoid will work using the Arduino, you just need a large enough 12V power supply. You just need to power the solenoid separately and just use the Arduino and Transistor to switch the ground connection. The limitation is not the Arduino, it is your power supply that is the limitation.
@harsh1626
@harsh1626 Жыл бұрын
can we connect 6 solenoids with arduino uno
@DIYTechGuyShow
@DIYTechGuyShow Жыл бұрын
Yes, you can connect as many solenoids as you have digital pins, just use a different pin for each solenoid or group of solenoids that you want to independently control. You will need a power supply large enough for all 6 solenoids if they will be used simultaneously.
@abdullahmemon6908
@abdullahmemon6908 3 жыл бұрын
Is solenoide a 12v?
@DIYTechGuyShow
@DIYTechGuyShow 2 жыл бұрын
Yes, it is a 12V solenoid.
@ritikjain5214
@ritikjain5214 3 жыл бұрын
Can u give the circuit diagram of it?
@DIYTechGuyShow
@DIYTechGuyShow 3 жыл бұрын
The circuit diagram is in the video.
Arduino Lesson 5 - PIR Motion Sensor
11:03
DIY Tech Guy
Рет қаралды 1,3 М.
Arduino Lesson 6   High Voltage Relay
13:17
DIY Tech Guy
Рет қаралды 4,7 М.
Looks realistic #tiktok
00:22
Анастасия Тарасова
Рет қаралды 105 МЛН
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 73 МЛН
Control a Solenoid with an Arduino (Tutorial)
20:01
Matt Inglot
Рет қаралды 211 М.
MOSFETs and Transistors with Arduino
40:50
DroneBot Workshop
Рет қаралды 1 МЛН
Design example of a single-fault-safe solenoid driver
19:37
Sam Ben-Yaakov
Рет қаралды 4,8 М.
How to make a powerful solenoid engine
12:42
American Tech
Рет қаралды 2,5 МЛН
How Bugatti's New Electric Motor Bends Physics
9:25
Ziroth
Рет қаралды 47 М.
What is a MAGNETRON - How Does it Work
10:41
Blueprint
Рет қаралды 1,1 МЛН
MOSFET or BJT?  Which is better to use with Arduino
16:00
learnelectronics
Рет қаралды 15 М.
MAGNETRON - Teardown + How It Works - Dangerous!
14:07
Electronoobs
Рет қаралды 896 М.
Fun Fun TV short film: 🙏baby save water😍
0:28
Fun Fun TV
Рет қаралды 10 МЛН
😱ВСЕМ БЫ ТАКИЕ СТАЛЬНЫЕ НЕРВЫ
0:18
MEXANIK_CHANNEL
Рет қаралды 7 МЛН
Всегда проверяйте зеркала
0:19
Up Your Brains
Рет қаралды 18 МЛН
貓媽媽🆚爆米花🌽🥷🍿 #aicat #shorts #cute
0:33
Cat Cat Cat
Рет қаралды 5 МЛН
POV Anxiety became a dad, but... | Inside Out
0:34
Future Fun
Рет қаралды 14 МЛН