Controlling a Servo Motor Using an Ultrasonic Sensor and Arduino

แชร์
ฝัง

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

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

    after going through more than 10 tutorials...this finally works for me...with clear instructions. Thank you! next i will need to know how to vary the distance and the servo movement

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

    thank you for this i had bought other parts that i used for the motor that i prefered but this tutorial is just so good

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

    Looked all over! yours was the best!!

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

    Thank you very much, it helps me a lot!

  • @lilenisly7459
    @lilenisly7459 5 ปีที่แล้ว

    I will be using this with my train set to make a auto crossing gate. Of course I will be adding blinking lights. Thanks for the helpful video.

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

    Thanks man you really helped me out with my project

  • @griffinhaydon4973
    @griffinhaydon4973 5 ปีที่แล้ว

    Very helpful thank you TechExult

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

    Great explanation 🙏🏽

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

    well explained...thank you sir..🤗

  • @verticealturass.a.s1721
    @verticealturass.a.s1721 6 ปีที่แล้ว

    excelente trabajo Dios les pague

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

    great video
    helped me a lot thanks

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

    Great video but I'm having trouble getting my servos to react to the ultrasonic sensor my servos will move 90 - 100 degrees but when my sensor is at the distance I programed my servos just slow down when I want them to go 90 - 80 degrees. What do you think the problem is?

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

    You are amazing thank you so much your explanation was great after watching so many videos that don make sense.

  • @bryan9749
    @bryan9749 4 ปีที่แล้ว +8

    OMG THANK YOU SIRR YOU HAVE JUST SAVED MY GRADES AND DIPLOMA DEGREE :D

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

    Thanks for the tutorial! Is there any way to lengthen the distance where your hand is sensed or can the ultrasonic sensor not do that?

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

      Hi Blake, you can lengthen the distance where your hand is sensed by changing the number 5 in the line "if (distance < 5)" to the number that you want. For example, if you want your hand to be sensed only within a distance of 100 cm from the ultrasonic sensor, please give that line as "if (distance

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

    thanks Sir, for your lesson. now i subscribed this channel, very educative. God bless

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

    Thank you very much!

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

    WE LOVE YOU!!!

  • @mohamedibrahim871
    @mohamedibrahim871 5 ปีที่แล้ว

    if I want the servo motor to stop the movement, what is changing in the code?

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

    I guess it could also work the other way around? Like as long as the sensor detects ur hand. The motor wont start the circlesaw?

  • @user-le4sr9yv7f
    @user-le4sr9yv7f 4 ปีที่แล้ว +1

    First thank you !
    i use your code and i add led work at the same time with the servo motor.
    i will print a facility for Hand sanitize

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

      Can you post your project?

  • @khurammajid
    @khurammajid 6 ปีที่แล้ว

    fantastic! well explained sir

  • @jeriwolfcr7838
    @jeriwolfcr7838 5 ปีที่แล้ว

    My kit came with a stepper motor. I tried to connect it with the stepper but it doesnt work once I connect it with the Ultrasonic Sensor

  • @andifiqihzulfikarashari2819
    @andifiqihzulfikarashari2819 5 ปีที่แล้ว

    Hello, can i use the code for another servo, like Servo MG995?

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

    hats off

  • @user-wb2zm5nn5z
    @user-wb2zm5nn5z 4 ปีที่แล้ว

    How do u make it for just 1 DC motor? Please answer...

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

    thank you

  • @seiminhaobaite3399
    @seiminhaobaite3399 4 ปีที่แล้ว

    Can we use da big servos???

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

    Much appreciated :)

  • @lalutriawanrinovianung5267
    @lalutriawanrinovianung5267 5 ปีที่แล้ว

    how if i make an interface between 2 arduino to control servo by ultrasonic sensor

  • @adhius2825
    @adhius2825 6 ปีที่แล้ว

    Hi, I have the issue where the servo motor keeps on spinning forever, instead of turning 90 degrees and then back again. I've directly copy+pasted your code and uploaded it numerous times. Suspecting that I'm using the wrong kind of servo motor ( MS-R-1.3-0 OLIMEX). Which one are you using in the video?

    • @adhius2825
      @adhius2825 6 ปีที่แล้ว

      [SOLVED] Just tried it with another type of servo motor, and it worked!

    • @techexult2537
      @techexult2537  6 ปีที่แล้ว

      I used Sg90 Micro Servo (9g)

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

    says for me, echo pin was no declared in this scope???

  • @yossishi221
    @yossishi221 5 ปีที่แล้ว

    hi
    Can you help me please?
    I want some distance sensor for (20cm) with adjustment option if there is, and with dry contact open/close.
    so, when it detects Obstacle it will open the dry contact and automatically close it when it will stop detect the Obstacle
    can you help me to find the item that I need on AliExpress?
    Thanks
    Yossi

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

    Bro small help can you draw a diagram of the circuit please so it is easy to understand

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

    my servo did not working at all even after changing with new servo motor 9g SG90... help me!!!!!!!!!!!

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

    Heyy I tried reaching link you saved for the code but it does not appear

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

    Amazing

  • @rajeshb9891
    @rajeshb9891 6 ปีที่แล้ว

    Thanks a lot bro

  • @ManasMantriawesome
    @ManasMantriawesome 6 ปีที่แล้ว

    hello we have tried your code, and we got our servo to work, however it will not turn 90 degrees and then turn back. However it continues to turn in the same direction, and simply changes the direction of rotation when we release our hand or object.

    • @techexult2537
      @techexult2537  6 ปีที่แล้ว

      I just checked the code and it's working fine. Please try to upload it again

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

    Sir Where Do i input my code

  • @cuongnguyenmanh3430
    @cuongnguyenmanh3430 5 ปีที่แล้ว

    please I asked you: i connected correctly to arduino, but when you load the code (though not load the library up), arduino lighting up , but servo is only spinning 2.3 round and stop, the ultrasonic sensor is not work, hope you help me, thank you very much!

    • @techexult2537
      @techexult2537  5 ปีที่แล้ว

      I would start by checking the wiring for the Sensor and then make sure that the pins are in their right sequence. Instead of writing the code from stretch try to copy and paste so that you don't miss anything. The CODE is correct and should work if everything is fine.

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

    Code is not available in the link. Please share

  • @shubhammohanty1098
    @shubhammohanty1098 5 ปีที่แล้ว

    Tech exult
    I can't find the detail button for this project on your website.Can you please send me the code?

    • @shubhammohanty1098
      @shubhammohanty1098 5 ปีที่แล้ว

      Sir its solved . Actually I was using a smartphone so I was unable to find the 'detail' button so I turned on the desktop site then it worked fine.

    • @techexult2537
      @techexult2537  5 ปีที่แล้ว

      The code is there. You will have to click the detail button under the video. However here is the link: docs.wixstatic.com/ugd/22a975_7fc48286344544d2a2518c36943bd70f.pdf

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

    How would I get the servo to move 20 degrees whenever the ultrasonic sensor is triggered? I don't need it to go back to the start position.

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

      This is the code for that: #include
      #define trigPin 7
      #define echoPin 6
      Servo servo;
      int sound = 250;
      void setup() {
      Serial.begin (9600);
      pinMode(trigPin, OUTPUT);
      pinMode(echoPin, INPUT);
      servo.attach(8);
      }
      void loop() {
      long duration, distance;
      //Servo Motor Controlled By Ultrasonic Sensor
      digitalWrite(trigPin, LOW);
      delayMicroseconds(2);
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
      duration = pulseIn(echoPin, HIGH);
      distance = (duration/2) / 29.1;
      if (distance < 5) {
      Serial.println("the distance is less than 5");
      servo.write(20);
      }
      else {
      servo.write(0);
      }
      if (distance > 60 || distance

  • @sumitdebbarma1443
    @sumitdebbarma1443 6 ปีที่แล้ว

    ur code is not giving angle wise rotation insteat it gives continous rotation

  • @TheMovieGeek-gh9ur
    @TheMovieGeek-gh9ur 5 ปีที่แล้ว

    What are the colors of the wires that needs to be used? Its not clear enough

    • @techexult2537
      @techexult2537  5 ปีที่แล้ว

      Colors don't matter. You can use any colors you have available

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

    when it is not pluged into my computer the servo dosent move fully plz help.

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

    hey doe anyone know the code i am a beginer and i need some code for it thanks.

  • @inancgulsen1638
    @inancgulsen1638 5 ปีที่แล้ว

    I called this code everywhere and I found the most understandable:)I'm Bealif(inanç)

  • @Ryu-oz9ol
    @Ryu-oz9ol 5 ปีที่แล้ว +1

    You've explained good but the servo motor is not working after I uploaded your code to my Arduino board. I checked the connection of the jumper cables and they are firm too, so I don't know what's wrong. The output for the ultrasonic is being output to the serial monitor, but there is no response from the servo motor. Kindly give a solution for this as I've a month's deadline for submitting the project but this servo motor does not seem to work at all. Please provide the solution!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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

      Same problem for me, ultrasonic sensor works but motor doesn't :(

    • @Ryu-oz9ol
      @Ryu-oz9ol 3 ปีที่แล้ว

      @@shantanukudav2148 Well I did discover a workaround for that but it's been more than an year since I finished that project so I don't know how I could help you. I'd have helped you if I had remembered how to do it. Sorry man. I hope you finish it on time.

  • @sahilsoni6483
    @sahilsoni6483 6 ปีที่แล้ว

    I have connected all the components correctly, uploaded the program but still its not working, what to do sir????I need it urgently

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

      I check the program and it's correct. Make sure that the following connections are correct: Servo Motor: Make sure the orange wire from the Servo motor is connected to Digital Pin 8. Ultrasonic Sensor: Make sure that Trig Pin is connected to Digital Pin 7 and Echo Pin to Digital Pin 6. Finally, check your BreadBoard make sure it is receiving 5V from the Arduino and that there is ground GND for both the Sensor and Servo Motor.

  • @toyotadiyexpert9458
    @toyotadiyexpert9458 6 ปีที่แล้ว

    can you help with my project just like what youve done but with lcd. can you do that? and please provide schematic diagram and program thanks a lot in advanced

    • @techexult2537
      @techexult2537  6 ปีที่แล้ว

      I did one already. Here is the link:
      th-cam.com/video/hSb3qB3Axvg/w-d-xo.html

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

    can i have a code thats for spining 360 degrees pls

  • @andrewg.8589
    @andrewg.8589 2 ปีที่แล้ว

    I'm sorry but the code didn't work for me. Can you figure out what's wrong?

  • @projecttechcreator3681
    @projecttechcreator3681 6 ปีที่แล้ว +2

    How to increase the distance of sensor in codes

  • @sesi7972
    @sesi7972 5 ปีที่แล้ว

    Why does not it work? Is it possible that the servomotor is damaged?

    • @sicflik9109
      @sicflik9109 4 ปีที่แล้ว

      sesi79 lack of power maybe what servo?

  • @blekkettrecords
    @blekkettrecords 5 ปีที่แล้ว

    YOU ARE AWSOME

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

    weldone , is it right
    #include
    #define trigPin 7
    #define echoPin 6
    Servo servo;
    int sound = 250;
    void setup() {
    Serial.begin (9600);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    servo.attach(8);
    }
    void loop(){
    long duration, distance;
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    duration = pulseIn(echoPin, HIGH);
    distance = (duration/2) / 29.1;
    if (distance < 5) {
    Serial.println("the distance is less than 5");
    servo.write(90);
    }
    else{
    servo.write(0);
    }
    if (distance > 60 || distance

  • @toyotadiyexpert9458
    @toyotadiyexpert9458 6 ปีที่แล้ว

    please response :( i need you sir. im almost done im done on your movie but i need it with lcd monitor please help

    • @techexult2537
      @techexult2537  6 ปีที่แล้ว

      Here is the code link:
      docs.wixstatic.com/ugd/22a975_ac64d5bf20e944438cc36412e9a65746.pdf
      And this is the video
      th-cam.com/video/hSb3qB3Axvg/w-d-xo.html

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

    Saludos des de Coatzacoalcos, Veracruz, México o de la universidad Veracruzana o Ciclistas UV Coatzacoalcos en facebook:xd

  • @shubhammohanty1098
    @shubhammohanty1098 5 ปีที่แล้ว

    Otherwise it's awsome!!!

  • @325rola
    @325rola 4 ปีที่แล้ว

    LIFEEE SAAAVERRRRRR

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

    distance = (duration/2) / 29.1;
    I am getting a error in this line
    Can you please help me out in this.

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

      Hi Om Kulkarni, please try this code in that place - distance= duration*0.034/2;

  • @andrewg.8589
    @andrewg.8589 2 ปีที่แล้ว

    I tried Three times but it didn't work.

  • @williamgilmore1671
    @williamgilmore1671 6 ปีที่แล้ว

    I’m getting the error code “redefinition of ‘void setup()’”

    • @williamgilmore1671
      @williamgilmore1671 6 ปีที่แล้ว

      Sathish blazer I fixed it. Thanks though

    • @shubhammohanty1098
      @shubhammohanty1098 5 ปีที่แล้ว

      William Gilmore can you please share the code.
      I can't find the code in the link.

    • @andrewg.8589
      @andrewg.8589 2 ปีที่แล้ว

      Me too. I tried Three times but it didn't work.

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

    Can u help me with the code I am a principal of a school and I want my students to engage in arduino more and more as I did when I was a kid

  • @dudekernal9452
    @dudekernal9452 5 ปีที่แล้ว

    Sir link is not here on the website plzz make video of code otherwise write the in reply ok sir bye i hope you solve my problem.

    • @techexult2537
      @techexult2537  5 ปีที่แล้ว

      Use this link: www.techexult.com/project-lessn. Then click the DETAILS button below the video you want a CODE for.

    • @shubhammohanty1098
      @shubhammohanty1098 5 ปีที่แล้ว

      Lasto bamboo
      First I was also unable to find the code. But it's now solved. If you are using a smartphone like me,then turn on desktop site from the menu section(3 dots in top right of screen), then you'll get it.

    • @shubhammohanty1098
      @shubhammohanty1098 5 ปีที่แล้ว

      Thank you

  • @Ceylingozlum
    @Ceylingozlum 5 ปีที่แล้ว

    Pls code?

    • @techexult2537
      @techexult2537  5 ปีที่แล้ว

      use the link provided below the video to get the CODE (www.techexult.com/project-lessn). Click the details button under the video that you need the CODE for and that will give you the CODE and instructions.

    • @Ceylingozlum
      @Ceylingozlum 5 ปีที่แล้ว

      @@techexult2537 thanks 😊❤

  • @projecttechcreator3681
    @projecttechcreator3681 6 ปีที่แล้ว

    Sir please its urgent

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

    Who else is at school

  • @marekkrhutek8587
    @marekkrhutek8587 6 ปีที่แล้ว

    pls code pls

    • @techexult2537
      @techexult2537  6 ปีที่แล้ว

      The code is no my website. Click on the link provided below the video and it will take you to my website. Go to the program page and look for the video you need and click details.

    • @marekkrhutek8587
      @marekkrhutek8587 6 ปีที่แล้ว

      Atleast please direct link, your webside sucks

    • @techexult2537
      @techexult2537  6 ปีที่แล้ว

      Thanks for the feedback

    • @marekkrhutek8587
      @marekkrhutek8587 6 ปีที่แล้ว

      The code

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

      in the flippin description