DC Motor Control with an H-Bridge and Arduino (Lesson #17)

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 พ.ค. 2024
  • Science Buddies Electronics Kit for Arduino: www.homesciencetools.com/prod...
    Learn to use an L293D H-bridge with an Arduino for direction and speed control of a DC motor. This is very useful for a variety of robotics projects that you can find on our site and TH-cam channel. See our complete playlist of Arduino tutorials here: • How to Use an Arduino and the Science Buddies website for cool science projects you can do with an Arduino: www.sciencebuddies.org/search...
    0:00 introduction
    1:52 H-bridge datasheet
    2:56 breadboard layout
    9:53 hard-coded motor behavior
    13:06 controlling motor direction with buttons
    15:25 controlling motor speed with a potentiometer
    Science Buddies also hosts a library of instructions for over 1,500 other hands-on science projects, lesson plans, and fun activities for K-12 parents, students, and teachers! Visit us at www.sciencebuddies.org to learn more.
    #STEM #sciencebuddies #arduino #electronics #programming
    *******************************
    Connect with Science Buddies:
    TWITTER: / sciencebuddies
    FACEBOOK: / sciencebuddies
    INSTAGRAM: / scibuddy
    PINTEREST: / sciencebuddies

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

  • @chitobalazo
    @chitobalazo 4 หลายเดือนก่อน +5

    Thanks for the video, now understanding the H bridge which is L293D incorporated in controlling a DC motor. Thank you very much.

  • @rubaiyatfoyez
    @rubaiyatfoyez 27 วันที่ผ่านมา

    I don't have any words to thank you! Just can't express how helpful this video has been.

  • @whatsupbudbud
    @whatsupbudbud 4 หลายเดือนก่อน +4

    Thanks for the video! Didn't know it's possible to test out arduino stuff in software. Will be useful especially when messing with batteries and condensers which can blow up.

  • @user-mx6bk5ip9e
    @user-mx6bk5ip9e 2 หลายเดือนก่อน +2

    your videos are amazing they are fun and infomativ. I finally understand everything thanks

  • @sagetk2981
    @sagetk2981 9 หลายเดือนก่อน +2

    This helped me a lot in my project. Would be nice if you included the link to the project

    • @Science.Buddies
      @Science.Buddies  8 หลายเดือนก่อน

      This is a general tutorial, but we have many specific projects on our site that use this circuit, such as www.sciencebuddies.org/science-fair-projects/project-ideas/Robotics_p042/robotics/arduino-self-driving-car

  • @hiryu6672
    @hiryu6672 3 หลายเดือนก่อน +1

    Thanks, this worked for me.

  • @tedbastwock3810
    @tedbastwock3810 หลายเดือนก่อน +1

    Absolutely fantastic video. I will be experimenting with doing this with Arduino Uno and also a PIC. Thank you!!!!

  • @johndiamond2548
    @johndiamond2548 5 หลายเดือนก่อน +1

    Great work! :)

  • @skipsmessyworkbench
    @skipsmessyworkbench 4 วันที่ผ่านมา

    The one thing that you should teach students is that with a switch, you should always make/break the hot side, (the plus voltage side) and never switch the ground. This is a safety issue and if your students go out into the world they will be forced to always break the hot side. Therefore, one side of a switch should be wired to +Voltage, the other side of the switch should have a 10K ohm resistor to ground and the arduino digital pin is wired to the junction of the resistor and the switch. With this configuration the wiring meets the NEC in all 50-states. I know in the hobby world it doesn't matter, but you never know if your students are working, or will be working in industry.

  • @lovemadeinjapan
    @lovemadeinjapan 5 หลายเดือนก่อน +1

    Thanks, I've some questions:
    Is hooking up 4 GND pins needed? They are for cooling, and the clamps in the board will cool them. The 6V input is also a single pin, and it has the same current going through.
    Do you need to set the pins as output? As there are a bunch of power transistors in the IC, won't they work on the default low-power output? Or do they need full 20mA to trigger?
    Can you set Tinkercad to put wires on top, now they dive under the IC which looks very weird.
    Does a LEGO motor work the same? How to change speed/power in code?

    • @Science.Buddies
      @Science.Buddies  5 หลายเดือนก่อน

      Hi - you have a lot of questions here, more than we can address in a single TH-cam comment. You may be able to get more answers on the official Arduino forums or forums dedicated to electronics like on Reddit or Stackexchange.

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

    Thank you, you helped me a lot :)

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

    Hey, this is a fantastic video! I do need a hand with something though. I am trying to use this circuit to control a vinyl player (conceptually). I have allocated a button for forward and reverse but I want to use two potentiometers. One at max speed would turn the disc at 33 revolutions per minute and one would turn it at 45 revolutions per min. How do I map both with the same speed function? or what do i even do hahaha thanks :)

    • @Science.Buddies
      @Science.Buddies  6 หลายเดือนก่อน

      Hi - unfortunately we can't provide support to write code for individual projects like this. We have many other videos in our tutorial series, including earlier videos specifically about buttons and potentiometers that may help, but putting it all together to do exactly what you want is up to you :-). You may be able to get help with your code on the official Arduino forums.

  • @ki3aki0
    @ki3aki0 4 หลายเดือนก่อน +1

    Thanks a lot it realy helped me

  • @atlas5097
    @atlas5097 3 หลายเดือนก่อน +2

    This video is great but I cant really wrap my head around how the motor is connected to the breadboard. I tried the code after putting everything in place, double checked the wires and it didnt work but idk if my motor is conected correctly. I also was wondering what arduino version you use.

    • @Science.Buddies
      @Science.Buddies  3 หลายเดือนก่อน +1

      If you're having trouble we recommend starting at the beginning of our Arduino tutorial playlist (linked in the description) and also watching our How to Use a Breadboard video: th-cam.com/video/6WReFkfrUIk/w-d-xo.htmlsi=byMxk5OcEK-xG2Df. The H-bridge is a more complicated circuit so it will be challenging if this is the first thing you're trying to do. Our videos show the Arduino UNO R3.

  • @Dan-nm2ne
    @Dan-nm2ne 2 หลายเดือนก่อน

    Can you explain why do you need a common ground? 9:45

  • @Sander-fx1mb
    @Sander-fx1mb 17 วันที่ผ่านมา

    You mentioned that we weren't going to use a 2nd motor, if I wanted to use 2 motors how would I do that?

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

    And also is it possible to toggle direction with the button instead and have the speed controlled by the potentiometer?

    • @Science.Buddies
      @Science.Buddies  6 หลายเดือนก่อน

      Yes, this should be possible.

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

    Can u make a tutorial on how to use a motor driver

    • @Science.Buddies
      @Science.Buddies  8 หลายเดือนก่อน

      We don't currently have plans for a separate motor driver tutorial, but many motor driver boards are simply breakout boards for an H-bridge like the L293D.

  • @eftihisprotop.9073
    @eftihisprotop.9073 16 วันที่ผ่านมา

    can you make a dc motor spin with a joystick using the same chip ? i cant figure it out.
    my moter wont stop spinning

  • @user-sv5om5wr7b
    @user-sv5om5wr7b 3 หลายเดือนก่อน

    Hi,thanks for your video.I have some questions:If i use the switch to control the motor ,when i push the first switch button it can clockwise rotation,but when i push it again,it can not stop. And then i push the second switch button------- it makes clockwise rotation slowly but can not counterclockwise rotation, and then if i do not push the second button,it still clockwise rotation without slowly condition.I do not know why..Could you please help me ?

    • @user-sv5om5wr7b
      @user-sv5om5wr7b 3 หลายเดือนก่อน

      Maybe the HIGH and Low is not clear in the code,and when i modify a little code ,it works.....

  • @user-om9pw8lf4k
    @user-om9pw8lf4k 8 หลายเดือนก่อน

    what simulator you are using?

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

      It's called TinkerCAD (you can see the logo in the top left corner)

    • @Science.Buddies
      @Science.Buddies  8 หลายเดือนก่อน

      The simulator is called Tinkercad Circuits, we have a separate tutorial about it here: th-cam.com/video/9RF_BZ1Cg4k/w-d-xo.htmlsi=9QhBv4rMeamxNTDF

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

    Hey, I don't mean for it to look like I'm asking for tech support, but I decided it worth asking anyways. In following along with the video, I got stuck when I went to try to add the two buttons in by myself. I then tried to just copy why you had done, but the motor would just run at 83rpm without any input, and would only change (to 0) while holding down but2pin. All this on Tinkercard by the way. Is it possible for you to tell me what I'm doing wrong?

    • @Science.Buddies
      @Science.Buddies  4 หลายเดือนก่อน

      Hi - if you're a student doing a science project, you can ask for help in the Ask an Expert forums on our website: www.sciencebuddies.org/science-fair-projects/ask-an-expert-intro, which is monitored by volunteers. Unfortunately we're a small organization and don't have the capacity to provide tech support beyond that, but we'd recommend starting earlier in our Arduino playlist (linked in the description) and check out the video about buttons before you move on to motors and H-bridges.

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

    Hey, great video. But I am confused, whenever I hook up a small DC motor to this circuit the motor doesn't work. The motor works when I take it off and plug it directly to the battery pack. Do I just need a bigger battery?

    • @Science.Buddies
      @Science.Buddies  5 หลายเดือนก่อน

      To clarify, you need to have Arduino code running for this circuit to work, the motor won't just spin if you plug it directly into the H bridge.

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

      Yes, the circuit did have code running, but I found that if I give it a little push it will spin slowly. I think I just need a bigger battery.

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

    Im looking to see how to control a dc motor without buttons or switches. Just coded movement. How do i do this? Tutorials??

    • @Science.Buddies
      @Science.Buddies  6 หลายเดือนก่อน

      Hi - we recommend checking out our full Arduino tutorial playlist. You can control the motor's movement using hard-coded digitalWrite commands and delays, just like you would when blinking an LED as covered earlier in the playlist. This does not require any buttons or switches as inputs.

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

    Is there an alternative way to power this like with a 9 volt battery to the Arduino

    • @Science.Buddies
      @Science.Buddies  4 หลายเดือนก่อน

      In general you don't want to use a 9V battery to power motors as they will drain the battery very quickly. Check out this video to learn more about your options for powering Arduino projects: th-cam.com/video/I7MrL5Q7zvY/w-d-xo.htmlsi=zagNwvLt5MSBBGNQ

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

    So can this be applied to 2000 rpm 12 V motor too?

    • @Science.Buddies
      @Science.Buddies  6 หลายเดือนก่อน

      The same concept applies but you will need to check the datasheet for your motor to see how much current it requires, and make sure the H bridge you purchase can handle that much current.

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

      ​@@Science.Buddies so my plan is to first try and write the code for a small simple motor
      Then I can use a large motor also I got some recommendations to use a l298n module

    • @Science.Buddies
      @Science.Buddies  6 หลายเดือนก่อน

      The code should be the same regardless of the motor size.

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

      @@Science.Buddies ok thank you sir

  • @user-ly1jo3nb3x
    @user-ly1jo3nb3x 6 หลายเดือนก่อน

    Hi, I am struggling to get this to work with no buttons. I have included Motor.h and Arduino.h and used your exact code. I get the error message of;
    C:\Users\cespa\OneDrive\Documents\Arduino\libraries\L298_Motor_Driver\Motor.cpp: In member function 'void Motor::goPercentage(uint8_t)':
    C:\Users\cespa\OneDrive\Documents\Arduino\libraries\L298_Motor_Driver\Motor.cpp:101:13: error: 'speed' was not declared in this scope
    checkWrite(speed);
    ^~~~~
    C:\Users\cespa\OneDrive\Documents\Arduino\libraries\L298_Motor_Driver\Motor.cpp:101:13: note: suggested alternative: '_speed'
    checkWrite(speed);
    ^~~~~
    _speed
    exit status 1
    Error compiling for board Arduino Uno.
    Please help, thanks!

    • @Science.Buddies
      @Science.Buddies  6 หลายเดือนก่อน

      When you get an error message like that, it helps to google specific parts of it (not necessarily the parts with the file path on your computer, since that won't match what other people have when encountering the same error). When you see something like "error: 'speed' was not declared in this scope" that usually means a variable was not declared properly, e.g. "int speed" may be missing from the beginning of your program. Going forward, we can't provide much debugging help in TH-cam comments, but the official Arduino forums can usually help.

  • @omarbravestone3221
    @omarbravestone3221 27 วันที่ผ่านมา

    can you start putting the code down below so we can copy and paste. Please!!!

    • @Science.Buddies
      @Science.Buddies  23 วันที่ผ่านมา

      Hi - unfortunately the TH-cam description field doesn't like Arduino code and the formatting gets messed up. For most of our newer videos there is a link to a Tinkercad Circuits simulation where you can copy the code, we're sorry we don't have it for all the old ones!

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

    my h bridge overheats super fast

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

    program not working