Arduino Tutorial 38: Using a Tilt Switch Cut Off With a DC Motor

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2019
  • You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
    / paulmcwhorter
    In today's lesson we demonstrate how to incorporate a tilt switch cutoff into a DC motor project. This is a useful method for cases where you would like to automatically turn your motors off in the case your project/device turns over or tips. This feature can be useful in a number of different projects and prototypes.
    You can get the kit I am using for this series at the following link:
    amzn.to/2I7N4Ek
    Follow these lessons on our FREE web site:
    toptechboy.com/arduino-tutori...
    [Disclosure of Material Connection: I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com. This means if you visit the link and purchase the item, I will receive an affiliate commission. Regardless, I only recommend products or services I use personally and believe will add value to my readers.]
    #Arduino
  • НаукаНаука

Комментарии • 405

  • @coltongerber4498
    @coltongerber4498 2 года назад +16

    I did the homework on the last episode no problem and decided to use the knowledge Ive gained so far afterwards to combine my DC Motor, Servo, and Joystick , X controlling motor speed/direction , Y controlling servo position to point the fan in a desired direction. My longest code so far and was successful right away. Fantastic teaching I can’t thank you enough !

    • @426F6F
      @426F6F Год назад

      Great idea, Colten!

  • @arseivan
    @arseivan Год назад +2

    Great lesson! Here is the code I ended up having before watching the video:
    void loop() {
    bool tiltVal = !digitalRead(tiltPin);
    digitalWrite(directionPin1, HIGH & tiltVal);
    digitalWrite(directionPin2, LOW & tiltVal);
    analogWrite(speedPin, mSpeed);
    }

  • @Anmol-AK
    @Anmol-AK 6 месяцев назад +2

    Completed the homework under 30 minutes on my own. Thanks a lot for your teaching sir

  • @LeonJakub
    @LeonJakub 3 года назад +3

    Did the homework! When you see people only viewing for 3 minutes I think you'll find it's people just revisiting sections of tutorials they have watched in entirety previously to help better understand the one they are currently working on. I have certainly done this on multiple occasions!

  • @nickr8747
    @nickr8747 4 года назад +6

    Keep doing these videos. they may not be crazy popular, but you have no idea how much these videos help us.

  • @pappgergely5031
    @pappgergely5031 4 года назад

    Thank you Paul! I am happy to have you here!

  • @caripatd232441
    @caripatd232441 3 года назад +2

    I made it Mr. McWhoter. Great video as always. I will finish this course to the end. So far I haven't had any problem and I've managed to pull out every assignment before see in you doing it. I always watch your videos up until the last second. Thank for your hard work doing these videos.

  • @christophechalons9072
    @christophechalons9072 3 года назад +2

    Did my homeworks, even managed to control speed and direction with a pot and a pushbutton (using the INPUT_PULLUP status given by one of your followers)... I'm so happy that 2 days ago I didn't even know how to use a component... now I just feel like understanding is at hand !
    What I like the most is when you explain by physics and math how and why things work in a component. It's so helpfull !

  • @moniftormos6881
    @moniftormos6881 4 года назад

    Great teacher ! I have been watching your videos since a week and now I have reached this lesson. Wish you a great day for you and you granddaughter.

  • @tiberiumihaescu7348
    @tiberiumihaescu7348 4 года назад +1

    I'm watching your videos up until the last second. Thank you so much for your work!

  • @noelomeli1520
    @noelomeli1520 3 года назад +1

    Homework done and now on to the next one! Thank you for the great lessons!

  • @ericsmith7988
    @ericsmith7988 3 года назад

    I used the tilt switch and also used the photo detector,. they work great together. The motor does slow down with low light and full speed at full light. Thank you Paul always a good day to watch your lessons.

  • @mrktm65sx
    @mrktm65sx 6 месяцев назад

    Completed homework on my own. Looking forward to the next tutorial. Thanks Paul!

  • @dannycollins5698
    @dannycollins5698 Год назад

    Finished the homework before watching this. I used an else statement instead of another if statement.
    Thank God for you! God bless you sir!

  • @adamcurtice3584
    @adamcurtice3584 2 года назад

    I completed the homework prior to watching this lesson. The logic was pretty straight forward. I used an If-Else statement to solve the logic. It worked great with very little issues. Thanks for the knowledge.

  • @danielsaenz5570
    @danielsaenz5570 2 года назад +2

    I did it ;) (it was kind of easy) Thanks so much for all these AMAZING TUTORIALS!!
    These homework assignments are so important I am so glad you do them!!

  • @katherineclarke4435
    @katherineclarke4435 3 года назад

    BOOOOOM!!! Did it all by myself, coded it a slightly different way. Tilt sensor wasn't working at first, narrowed it down to hardware issue through your excellent de-bugging training; moved it away from the columns occupied by L293D and giddy up!!!! Success!

  • @andrewhodson8346
    @andrewhodson8346 3 года назад

    Hi Paul. Did my homework and very close to your solution. I also pointed out your baud rate error in my comments to Tutorial 37. Really enjoying these tutorials. Thanks

  • @fjdelahoz
    @fjdelahoz 4 года назад

    Happy Thanksgiving Paul to you and your loved ones. I enjoy your lessons very much and am looking forward to the next one!

  • @jbelmont72
    @jbelmont72 Год назад

    love these. I used a nested if loop to give the motor the "kickstart" so I could initiate spinning at a lower RPM.

  • @donalddalrymple1776
    @donalddalrymple1776 4 года назад

    My version was about 90% the same as your version including pin and variable names. I lean toward the if/else versus the if/if approach. Good lesson, getting more comfortable with the thought process for the design. Keep it up, thanks.

  • @srduke
    @srduke 4 года назад +2

    I absolutely love these lessons. Lets have a "Yippy i yay" for Paul

  • @hasan-motam
    @hasan-motam Год назад

    I did the homework without a problem. Thanks once again Paul.

  • @blazenbunny84
    @blazenbunny84 3 года назад

    Tried it hands on and was successful in completing my homework :) Thankyou so much!!!

  • @stephenmarshall1286
    @stephenmarshall1286 4 года назад

    Yes did the homework and worked great. I like the fact you make mistakes (whether deliberate or not) as this makes us analyse the issue.

  • @thefierceninja2557
    @thefierceninja2557 2 года назад

    I did the homework with flawless victory! Can't wait to start on the joystick controls!

  • @tedsykora1858
    @tedsykora1858 4 года назад

    watching start to finish and doing the homework. Fun and helpful series.

  • @tntragan
    @tntragan 2 года назад +1

    Did the homework. I used a while loop instead and it worked quite nicely. Had to take the delays out like you did. I was yelling at you about the analogWrite instead of the digitalWrite. My wife thinks I'm crazy.

  • @user-ys6bc7yh7z
    @user-ys6bc7yh7z 8 месяцев назад

    Assignment is completed!
    Love your lessons and started to learn math because of your inspiration!
    Thank you very much.

  • @Europayacht
    @Europayacht 4 года назад

    Very very educating to me and my friends, really dragged us into the µC buissness. Thanks to Paul !

  • @jessekloberdanz246
    @jessekloberdanz246 2 года назад

    Love the videos! We appreciate you. I did this one a bit different, but your way seemed to work better.

  • @muhammadrafiqulislamkhan6994
    @muhammadrafiqulislamkhan6994 2 года назад

    This another great project for me. I am waiting for next one. Thank you very much.

  • @markfuentes3666
    @markfuentes3666 4 года назад

    I complete the home work. Worked great. Did it the same as you. Thanks for these videos.

  • @glennfelpel9785
    @glennfelpel9785 4 года назад

    Another good lesson. At the pace you are presenting them I am able to keep up and to do the homework. Will have this one done for next week.
    See you then. Thanks you for the training.

  • @user-vf7fx2ff9d
    @user-vf7fx2ff9d Год назад

    Hi Paul, I looked the lesson until the end :-) ...and I made my homework! I appreciate your effort for teaching us very much! Thank you a lot!!!

  • @higuy2k
    @higuy2k 4 года назад

    Did the homework between lessons. Got it working, after watching you code it, I had to look over my shoulder to see if you had watched me write the code, almost identical right down to variable names. 😀

  • @philnewman1110
    @philnewman1110 Год назад

    Still there watching all the way through to the very end Paul, as always a very interesting tutorial, thanks again!!

  • @richardbritain7435
    @richardbritain7435 2 года назад

    Brilliant!! I managed the tilt and stop homework on my own. The next project looks tricky though. Thanks.

  • @AlexDavis-ch1ro
    @AlexDavis-ch1ro Год назад

    Super challenging homework, but mostly was able to do it. Thanks for your great instruction!

  • @pudgepatenaude3481
    @pudgepatenaude3481 3 года назад

    Boom, done already on my own from homework assignment. you are an excellent teacher. thanks so much.

  • @michaeldalfonzo3912
    @michaeldalfonzo3912 2 года назад

    Did the homework and got it working just fine. This one was easy.

  • @Rob_TheOne
    @Rob_TheOne 3 года назад

    Using this to control an rc crawler thank you! Back to the servo and IR control lessons. Glad I did my homework and mapped my buttons.

  • @TheSelfUnemployed
    @TheSelfUnemployed 2 года назад

    The tilt switch homework was easy and ill be getting to work on the joystick HW in the morning as it is getting late. Thanks you Paul!

  • @matthewstone898
    @matthewstone898 8 месяцев назад

    Was able to do this, simple enough and added a active buzzer as part of the tilt.

  • @TheParksy72
    @TheParksy72 3 года назад

    did the homework, love that I just know how to do it. It's all thanks to you, my good sir.

  • @panzerblitz8226
    @panzerblitz8226 2 года назад

    I did the HW before watching , and it was working, thanks to your great explanations about tilt function earlier! Thanks again, you are the perfect teacher.

  • @richardletourneau2672
    @richardletourneau2672 4 года назад

    I did the assignment after few corrections it work OK. After I put the decimal point everything work fine. Thanks again.

  • @VegasGuy89183
    @VegasGuy89183 Год назад +2

    I did my homework and had it working prior to watching this episode. Setting the motor speed to zero seemed logical, so that's what I did. The only mod I made was to put the tilt-switch on a couple of male/female wire extensions to make the tip-over testing easier. Thank you for another wonderful lesson. 👍

    • @kriegschwert
      @kriegschwert Год назад

      Haha, putting the tilt switch on extensions was a great idea, thanks!

  • @muhammadrafiqulislamkhan6994
    @muhammadrafiqulislamkhan6994 2 года назад

    Every projects I love. Thank you.

  • @tdc485
    @tdc485 3 года назад

    I did it myself. I also added a potentiometer to control the speed and a button to change direction. Off to do the joystick assignment now.

  • @johntello8904
    @johntello8904 3 года назад

    I did my homework. I only added one if statement in my code, so that when tiltVal == 1, the command digitalWrite(speedPin, LOW) was executed. Thanks for the great lesson Paul!

  • @kevhopkins984
    @kevhopkins984 3 года назад

    Enjoyed, and yes I did do the Homework, not quite the same way you did, but still with success.

  • @tallslimpr
    @tallslimpr 3 года назад

    Im here Paul, til the end. Thank you !

  • @RavensHammer00
    @RavensHammer00 Год назад

    Watched to the end, and your coding was almost exactly like mine! Thank you! Off to do more homework!

  • @Mrgasman1978
    @Mrgasman1978 Год назад

    Rose amd Ronald! I always watch all videos to the end and more than once!.

  • @lesliejames5722
    @lesliejames5722 2 года назад

    Rose and Ronald, another good lesson thanks Paul.

  • @clairsmyers3571
    @clairsmyers3571 4 года назад

    Mr McWhortor, I just received the elegoo super starter kit today. I should have gotten that a long time ago. I had a problem getting the board going but checked the com channel and it was different than my Arduino. I changed that and, it is working fine and ran the sketches that I uploaded to it. I'm good to go and now I have the sensors to follow your videos. Thanks for the advice. That starter kit is absolutely the way to go.

  • @marksholcomb
    @marksholcomb 3 года назад

    Did homework, but, simply put the tilt switch in series with Vcc. Thanks for another great lesson.

  • @muhammaddanial50
    @muhammaddanial50 3 года назад

    Did my homework in just 5 mins time thanks to you paul💯

  • @OtAkU10505
    @OtAkU10505 4 года назад

    I ALWAYS do my homework Paul!! Love your videos!

  • @jabber2824
    @jabber2824 2 месяца назад

    Yes I always do the homework and watch to the end :-) Great stuff incorporating earlier learned stuff.

  • @aideningraham7249
    @aideningraham7249 4 года назад

    Awesome video, cant wait for the next one!

  • @josemejias1054
    @josemejias1054 4 года назад

    i watched all your videos and theyre really good during quarantine. Thank you.

  • @travisrichardson5366
    @travisrichardson5366 4 года назад +1

    My coding was slightly different initially, but still got it to work. Yours was definitely more streamlined. On to my next homework assignment.

  • @johnkafer5061
    @johnkafer5061 4 года назад

    yup, did homework and solved it......you are an excellent teacher, giddyup...

  • @agustinruiz2081
    @agustinruiz2081 2 года назад

    I got it before to watch the video, basically it was easy applying the concepts I learnt in the 2 previous videos . I am looking forward to doing the next homework with the joystick.

  • @SimonChil
    @SimonChil 3 года назад

    Of course i've done my homework. Always do! I even tried to go further including a joystick on my own but i'll have to wait for the next lecture to figure it out.

  • @pratikdas1780
    @pratikdas1780 3 года назад

    Did it on my own, sir. Thank you for all the lessons. 38 down. 20 more to goooooo!!!

    • @pratikdas1780
      @pratikdas1780 3 года назад

      *30 more to go lol. sorry for the typo.

  • @josephcapell1494
    @josephcapell1494 3 года назад

    I always do my homework! Thank you for the videos.

  • @ianteague2929
    @ianteague2929 Год назад

    I'm definitely doing my homework. And I do watch all the way to the end of every episode .

  • @ylevite
    @ylevite Год назад

    This one was easy :) Thanks for the wonderful lessons!

  • @theknottyworkshopgeoffjung529
    @theknottyworkshopgeoffjung529 4 года назад

    Thanks for the video. Did the homework and got it on my own.

  • @marcusindicuz7757
    @marcusindicuz7757 4 года назад

    thank u so much for all the lessons. I did the homework without and extra code
    :)

  • @pralaymajumdar7822
    @pralaymajumdar7822 4 года назад

    Yes sir.....I am able to do the homework....I am eagerly waiting for the next Tuesday at 9:30 pm in India....Thank you.

  • @tonyperry6702
    @tonyperry6702 4 года назад

    Did my homework. It worked perfectly.

  • @shivanipawar7569
    @shivanipawar7569 4 года назад +1

    did my homework!!! and it was working perfectly fine....

  • @GeoGebweiler
    @GeoGebweiler 4 года назад

    Oh yes. I also did my homework and it worked fine :-) Thanks for teaching, Paul !

  • @1271344able
    @1271344able 3 года назад

    I did my homework before watching the video worked great. Todays homework is going to be fun really like how you assign homework to test your viewers learning progression though these series of videos.

  • @bleujaegel
    @bleujaegel Год назад

    Made it through the homework unscathed. Love the homework assignments!

  • @JohnSmith-lp5en
    @JohnSmith-lp5en Год назад

    Hey Paul, I sure did the home work plus I added the green and red LED to show a visual warning if the fan tipped over.

  • @kevincornelia4067
    @kevincornelia4067 3 года назад

    Did the homework on my own👌. My code was a bit different but it worked the same! Used and if, else statement 👍🏻.

  • @liquidalex772
    @liquidalex772 5 месяцев назад

    I love these videos i just started with arduino and this help so much

  • @thysdelport6782
    @thysdelport6782 Год назад

    Done and dusted. Added two motors due to the use of L298N board. Great tutorial yet again.

  • @orndorff52
    @orndorff52 4 года назад +27

    This one was cake!! The only thing to this point that I’m struggling to conceptualize is the toggle switch. It gets easier the more I practice with it tho

  • @freetjen
    @freetjen 11 месяцев назад

    Great tutorial as usual. Did the math already for the joystick and all works fine. I really love to do the homework in front, and then see how you did it afterwars. Start getting the hang on the math stuff 🤓. Can't thank you enough for taking the time and effort to explain all those things to us ✌

  • @Hino_55
    @Hino_55 4 года назад

    Great lesson Sir Paul, Thankyou!

  • @MarvPerk3
    @MarvPerk3 3 года назад +1

    Hi, Paul. Did the homework on my own successfully. Since the bread board is so big and I hate to have to tear it down and start over most times, I decided to see if I could combine lessons 35, 36, 37 and 38, both schematic and code, so I could run the whole shmear at once. So, now I have a reversible stepper motor driven by a toggle switch, a DC motor and fan running clockwise (so the air blows out/up from the blades), and both motors stop if the tilt switch goes to 1... with green and red LEDs to indicate when it is normal vs "tilted". I'm sure the battery doesn't love running 2 motors at once, but the PS does seem to handle it. My board is quite full, but I didn't run out of pins! Fun!

  • @CarolinaDGF
    @CarolinaDGF 3 года назад

    Easy - once I remembered to do the resistor trick on the tiltPin. :) I am very much enjoying this series.

  • @hughpatterson1480
    @hughpatterson1480 2 года назад

    As I tell my students, any homework I give you, I do myself. I did the homework because the only way to really learn is to try things on your own. Doing this is really helpful because a day will come when there is no one to guide you but yourself. Thanks for another great video.

  • @yovavgur-ari9580
    @yovavgur-ari9580 Год назад

    Great lesson

  • @sammysam1503
    @sammysam1503 4 года назад

    I did this after the previous lesson all on my own! Loving the videos!
    int speedPin=5;
    int dir1=4;
    int dir2=3;
    int tiltPin=2;
    int tiltVal=0;
    int mSpeed=255;
    void setup() {
    // put your setup code here, to run once:
    pinMode(speedPin,OUTPUT);
    pinMode(dir1,OUTPUT);
    pinMode(dir2,OUTPUT);
    pinMode(tiltPin,INPUT);
    digitalWrite(tiltPin,HIGH);
    pinMode(buttonPin,INPUT);
    Serial.begin(9600);
    }
    void loop() {
    // put your main code here, to run repeatedly:
    tiltVal=digitalRead(tiltPin);
    analogWrite(speedPin,mSpeed);
    Serial.println(tiltVal);
    if(tiltVal==1){
    digitalWrite(dir1,LOW);
    digitalWrite(dir2,LOW);
    analogWrite(speedPin,mSpeed);
    tiltVal=digitalRead(tiltPin);
    Serial.println(tiltVal);
    }
    if(tiltVal==0){
    digitalWrite(dir1,HIGH);
    digitalWrite(dir2,LOW);
    analogWrite(speedPin,mSpeed);
    tiltVal=digitalRead(tiltPin);
    Serial.println(tiltVal);
    }
    }

  • @warsteelcalgarus5790
    @warsteelcalgarus5790 Год назад

    I am now able to add the tilt cut off with flashing red LED. Control the speed of the motor with a potentiometer. Turn the whole thing off and on and reset the tilt state with a button.
    I just wanted to take the time before finishing this video to let thank you for this series!
    You taught me how to do Fusion 360 and I'm so happy to continue to be able to learn from you.
    Reply

  • @oljeitulkhagva6288
    @oljeitulkhagva6288 3 года назад

    love the content keep it going

  • @ShockingTips
    @ShockingTips Год назад

    I was thinking about where a tilt switch is used and there is one in my portable heater that shuts it off to prevent fires. It also turns on a red light. Really useful information 👍

  • @aaronmilliman7685
    @aaronmilliman7685 Год назад +1

    Another great video. Thank you.

  • @garywilliams5962
    @garywilliams5962 3 года назад

    Did my tilt switch homework, pretty much the same except I used an “if else” command. Off to do my joystick homework now, looking forward to this, bit more challenging than the tilt switch 👍👍

  • @weversonbarbieri8986
    @weversonbarbieri8986 3 года назад

    Awesome Paul, May God bless you!

  • @shaikeshap
    @shaikeshap 2 года назад

    Great stuff!

  • @huhwhat2996
    @huhwhat2996 2 года назад

    Homework did, thanks Paul.

  • @opalprestonshirley1700
    @opalprestonshirley1700 4 года назад

    I did do the homework and it works well. Mine was slightly different than yours but with the same result. Your coding was a bit simpler though. Thanks Paul.