Robotics Programming: Servo and HC-SR04 Ultrasonic Sensor with Arduino

In this episode of robotics programming we bring together our Ultrasonic Sensor and Servo to create an array of distance information that our robot will be able to use for the advanced algorithms we will soon be creating. This is the last of the hardware and setup focused labs which leaves us with a complete robot ready to see and navigate around the world.
Here is the link to the Pololu documentation to fix the Timer Library: www.pololu.com/docs/0J69/3.9.1
Throughout this series we will be introducing topics on building and programming an autonomous mobile robot! You can follow along with each lab adding amazing new behaviors to you robot projects and learning the algorithms and tuning techniques that produce incredible robots! We will be exploring reactive algorithms such as PID, Potential Fields and A*. Along the way you will learn how to program behaviors such as object following, wall following, standing / balancing, go-to goal and object avoidance. This series is intended to allow you to follow along with your own robot.
Code access: Direct access to source code and additional resources are available by becoming a Coding Coach supporter. You can join and learn more here: codingcoach.net/sponsor . You may also copy the code from the video as you follow along.
This video series is meant to help anyone interested in programming robots follow along. You do not need to use the same robot as I do. Any mobile robot can run these same algorithms, you just have to tune the robot differently.
If you missed episode 1, you can find it here: • Robotics Programming: ...
Episode 2: • Robotics Programming: ...
Episode 3: • Robotics Programming: ...
The next video in this series: • Robotics Programming: ...
Playlist of the full series: • Robotics Programming Labs
Video that discusses the future direction of the series: • Robotics Programming: ...
Chapters:
0:00 Introduction
0:46 Arduino Timers Discussion
3:59 Code Overview
9:36 setup()
10:27 loop()
14:19 Timing Demo / Debugging
16:13 Ultrasonic Demo / Debugging
19:30 Conclusion
#codingcoach #arduinorobot #roboticsprogramming
Robot used
Pololu 3pi+: www.pololu.com/category/280/3...
Links to hardware: (Amazon Affiliate links)
S90 9g Servo (10 pack): amzn.to/3tmUhGN
Mini breadboards: amzn.to/2NeHXZA
Jumper Wire assortment: amzn.to/3bJD6Jh
470uf Capacitors: amzn.to/2ORqBSU
Break-away headers: amzn.to/3cwVapl
Other robots, batteries and tools
Elegoo Smart Car: amzn.to/3iG3uFO
Robot car chassis (with encoder cutout): amzn.to/3odlacY
Pololu Zumo: amzn.to/39TbaAC
Batteries:
EBL Rechargeable batteries: amzn.to/3pdiM7A
Micrometer Caliper Measuring Tool (To measure wheel diameter): amzn.to/3sQ0BqB

Пікірлер: 14

  • @maryskurt
    @maryskurt3 жыл бұрын

    Thank you for this!!! I like your vision for future episodes!

  • @CodingCoach

    @CodingCoach

    3 жыл бұрын

    Thank you for watching and for the feedback!

  • @melvinbullock5674
    @melvinbullock56743 жыл бұрын

    Another excellent video, Thankyou! In your videos you show some clips with Henry ix in, he has fixed multiple sensors. Do you have any information on how you integrate these into your code please? I have a similar design using five sensors, but I am not a coder! Mechanic by trade, mechanic by nature ;)

  • @CodingCoach

    @CodingCoach

    3 жыл бұрын

    You're welcome! The important thing to remember with multiple ultrasonic sensors is that they have a pretty wide (30 degrees or so) angle and you have to alternate them so they do not pick up each others pings. On a setup like Henry IX i alternate 2 banks of sensors (the left most, center, and right most being bank 1, and the two between those being bank 2). This way noise is reduced. You can trigger more than one at a time so long as their angle have enough spread. I relate to your last sentence, just in reverse :) I am obviously a computer scientist / software engineer by trade, but am currently starting to take the m96 engine out my old boxster to tear it apart and get my self lots of trouble (and fun hopefully) I am sure along the way. (I don't know if you are an auto mechanic, but I found that ironic either way).

  • @melvinbullock5674

    @melvinbullock5674

    3 жыл бұрын

    @@CodingCoach I'm using the Arduino NewPing library to run all five sensors, they are set out at the 30,60,90,120 & 150 degree marks and the NewPing times them seperately. I can get these readings back but one or two of them will "stick" at a distance reading or 0! so trying to trouble shoot this atm! Refrigeration mechanic :)

  • @CodingCoach

    @CodingCoach

    3 жыл бұрын

    @@melvinbullock5674 Reading of 0 means it is likely timing out or not getting a signal back. I usually set a limit check and change 0 readings into my MAX_DISTANCE.. If you put something in-front of that sensor and you are getting 0's then check the wiring and the sensor itself. If you are using the ping library then it would be calling the pulseIn() method most likely, but another thing to check would be the third parameter (the timeout length).

  • @YTbxg
    @YTbxg3 жыл бұрын

    Its very interesting though rather hard to follow without the ability to follow what you are saying by having the actual code to hand. I would like to put up you code on either another screen or a split screen to better understand the code. Github is good for code sharing.

  • @codecage9333
    @codecage93333 жыл бұрын

    What happened to updating the usPm to the usCm at the end of the usReadCm function?

  • @codecage9333

    @codecage9333

    3 жыл бұрын

    There I go with the "blind in one eye" thing again! I just realized we are not using usPm once we combined the motor and the sensor together. Maybe I should study what the code is doing a little longer before jumping in with questions. :-)

  • @CodingCoach

    @CodingCoach

    3 жыл бұрын

    no worries! glad you found it!

  • @Shubham-po2tp

    @Shubham-po2tp

    2 жыл бұрын

    @@CodingCoach Hello What is your opinion about plastic body of robot Can we use that robot without body What are disadvantages