Arduino Lesson 4 - Solenoid control using a Transistor

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 พ.ค. 2024
  • In this project you will learn how to connect a Solenoid Magnet to an Arduino using a transistor as a switch.
  • บันเทิง

ความคิดเห็น • 94

  • @aidanpawz2205
    @aidanpawz2205 2 ปีที่แล้ว +1

    Great video! Thank you for helping me understand how to use a solenoid. Your video was clear, quick, and understable.

  • @renegaed
    @renegaed 2 ปีที่แล้ว +4

    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.

  • @Lecandotnet
    @Lecandotnet 3 ปีที่แล้ว

    Thank you for the great helps on Arduino controls solenoid.

  • @Viktorr87
    @Viktorr87 2 ปีที่แล้ว

    I tried two other tutorials on youtube to no avail. This worked in an instant! Thank you!

  • @JDKoder
    @JDKoder 2 ปีที่แล้ว

    Great video. Thanks for sharing.

  • @TheTadek2001
    @TheTadek2001 ปีที่แล้ว +1

    Thanks, it works! Greetings from Gdynia Maritime University!

  • @wesselvandenbroek4576
    @wesselvandenbroek4576 2 ปีที่แล้ว

    yeaahh you helped us really well, thanks for the video man!!!

  • @Bianchi77
    @Bianchi77 ปีที่แล้ว

    Nice info, thanks for sharing it :)

  • @TangodownNZ
    @TangodownNZ ปีที่แล้ว +1

    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
    th-cam.com/video/8gx00X9qgzM/w-d-xo.html

  • @jaimecases3426
    @jaimecases3426 7 หลายเดือนก่อน

    Question: Can I use solenoid for a water despenser that will automatically stop when a cup is about to get full?

  • @lasanda8885
    @lasanda8885 2 ปีที่แล้ว +1

    Thanks ✋❤

  • @dumonr71
    @dumonr71 2 ปีที่แล้ว +1

    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.

  • @kennadyintercorp5510
    @kennadyintercorp5510 2 ปีที่แล้ว

    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

  • @raptorphotography2916
    @raptorphotography2916 6 หลายเดือนก่อน

    Champ🏆

  • @chrislewis3322
    @chrislewis3322 10 หลายเดือนก่อน

    A year on but could you wire up a switch to turn off and on the solenoid

  • @marcobucci
    @marcobucci 10 หลายเดือนก่อน

    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 10 หลายเดือนก่อน +1

      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 10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน

      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.

  • @prasannapujar5993
    @prasannapujar5993 2 ปีที่แล้ว

    can i use IRLZ34N MOSFET instead of TIP102 transistor does it also work with DC 12v solenoid valve???

  • @ayateleb9414
    @ayateleb9414 ปีที่แล้ว

    How do I simulate solenoid valve in proteus program?

  • @mayasmahmed8471
    @mayasmahmed8471 ปีที่แล้ว

    I want to ask you if I don’t have TIP102 Transistor which other type I can use?

  • @lunaartemisvods8812
    @lunaartemisvods8812 6 หลายเดือนก่อน

    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?

  • @prasannapujar5993
    @prasannapujar5993 ปีที่แล้ว

    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  ปีที่แล้ว

      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 ปีที่แล้ว

      @@DIYTechGuyShow ok I am clear now. thanks for ur reply 👍

  • @pbostjancic1
    @pbostjancic1 2 ปีที่แล้ว +1

    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.

  • @HaidenMcGrath
    @HaidenMcGrath ปีที่แล้ว

    Great video! Quick question, why would someone use this transistor method over a 5v relay module? Thanks

    • @DIYTechGuyShow
      @DIYTechGuyShow  ปีที่แล้ว +3

      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.

  • @piyushsonigara5550
    @piyushsonigara5550 2 หลายเดือนก่อน

    Sir can u please explain how do i connect 2 solenoid valves , in the same setup.

  • @williamwheeler8906
    @williamwheeler8906 6 หลายเดือนก่อน

    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.

  • @rickieyt8615
    @rickieyt8615 17 วันที่ผ่านมา

    im confused where did you use the external power source

  • @gorgigeorgie4594
    @gorgigeorgie4594 หลายเดือนก่อน

    thanks

  • @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.

  • @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.

  • @Ijustwatchfunnycrap
    @Ijustwatchfunnycrap 3 ปีที่แล้ว +1

    Could you explain how you would add a button to this setup?

    • @DIYTechGuyShow
      @DIYTechGuyShow  3 ปีที่แล้ว +2

      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. th-cam.com/video/skUlztFyJac/w-d-xo.html

    • @Ijustwatchfunnycrap
      @Ijustwatchfunnycrap 3 ปีที่แล้ว +1

      @@DIYTechGuyShow Thank you.

  • @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.

  • @user-tt6ij8zh8b
    @user-tt6ij8zh8b 5 หลายเดือนก่อน

    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 3 หลายเดือนก่อน

      Yea I noticed that too and got me confused. It looks like an open circuit with nothing connecting to the positive on the board.

  • @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.

  • @davidhollis8606
    @davidhollis8606 ปีที่แล้ว

    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  ปีที่แล้ว

      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.

  • @emzhang3268
    @emzhang3268 2 ปีที่แล้ว

    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.

  • @hamzi586
    @hamzi586 3 ปีที่แล้ว +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 ปีที่แล้ว +1

      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.

  • @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.

  • @MicaseHD
    @MicaseHD ปีที่แล้ว

    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.

  • @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.

  • @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.th-cam.com/users/videoKlxFC89gqpk/edit In that video I control a 120V lightbulb, but you could use the same design and relays to control 230V.

  • @sean-christianhatcher7074
    @sean-christianhatcher7074 10 หลายเดือนก่อน

    Is it possible to do this without that bread board?

    • @DIYTechGuyShow
      @DIYTechGuyShow  10 หลายเดือนก่อน

      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.

  • @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 10 หลายเดือนก่อน

      @@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?

  • @dumonr71
    @dumonr71 2 ปีที่แล้ว +1

    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  2 ปีที่แล้ว +1

      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.

  • @harsh1626
    @harsh1626 10 หลายเดือนก่อน

    can we connect 6 solenoids with arduino uno

    • @DIYTechGuyShow
      @DIYTechGuyShow  10 หลายเดือนก่อน

      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.

  • @jenna_junk
    @jenna_junk 2 ปีที่แล้ว +1

    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.

  • @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.

  • @abdullahmemon6908
    @abdullahmemon6908 2 ปีที่แล้ว

    Is solenoide a 12v?

  • @YashPatel-sh2ws
    @YashPatel-sh2ws 3 ปีที่แล้ว +1

    Where to apply 12 v?

    • @DIYTechGuyShow
      @DIYTechGuyShow  3 ปีที่แล้ว +2

      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.

  • @Barnyardbuilds286
    @Barnyardbuilds286 ปีที่แล้ว

    Can Someone copy and paste the code. i hat copy from videos i always mess up thx

  • @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.

  • @ritikjain5214
    @ritikjain5214 3 ปีที่แล้ว

    Can u give the circuit diagram of it?

    • @DIYTechGuyShow
      @DIYTechGuyShow  2 ปีที่แล้ว

      The circuit diagram is in the video.