Arduino Robot Car with Speed Sensors - Using Arduino Interrupts

379,489
0
Published 2017-12-08
Let's build a robot car that uses those slotted "optical speed sensors"! We'll also learn about Arduino Interrupts.

Get full instructions and Arduino sketches at dronebotworkshop.com/robot-car-with-speed-sensors/
More articles and tutorials: dronebotworkshop.com/
Join the conversation on the forum: forum.dronebotworkshop.com/
Subscribe to the newsletter and stay in touch:dronebotworkshop.com/subscribe/

In this video, I will show you how to assemble a very popular 2WD robot car chassis kit and how to use the speed sensor disks or “encoder wheels” that are included with the kit. You’ll learn how to couple the encoder wheels with a couple of inexpensive optical sensors that are based upon an optocoupler and an LM393 dual comparator chip, allowing you to measure speed and distance traveled.

These inexpensive kits can form the basis of a simple or sophisticated robot, you are only limited by your imagination (and budget and technical abilities LOL). I’ll show you an example of a robot I’m constructing that illustrates just how much you can expand upon the basic robot car chassis, and I’ll offer some suggestions for planning out your own unique robotic creation.

There are a couple of different styles of these kits, I will show you two of them. The main difference between them is in how the motors are mounted to the chassis - one uses an acrylic mount while the other uses a mount made of aluminum. Either type is perfectly fine to use for these experiments.

In addition to the robot car chassis kit and a pair of LM393-based optical sensors, you’ll need an Arduino Uno and an L298N H-Bridge motor driver, as well as a few batteries to power everything up. I’ll show you how to hook it all up and how to determine the optimum placement for these components on your robot car chassis.

I’ll then explain how the optical sensor works and how you can use its readings to determine not only speed but distance as well.

Then comes the code! If you are relatively new to Arduino programming then you might not have used “interrupts” before, so it’s time to learn something new. The Arduino Uno allows for two hardware interrupts and both will be used in this design.

Here is an outline of what’s covered in the video:

00:00 - Introduction
02:20 - Extra parts you’ll need
03:00 - Parts included with Robot Car Kit
04:54 - Planning your Robot Car design
08:24 - Building the Robot Car
10:13 - Speed Encoder & Opto Interrupter operation
11:18 - Speed Encoder & Opto Interrupter demonstration
12:46 - LM393-based Speed Sensor
13:21 - How a Comparator works
14:18 - Explaining Arduino Interrupts
18:04 - Arduino Speed Sensor demo setup
19:14 - Arduino Speed Sensor demo sketch
26:19 - Arduino Speed Sensor in action
27:27 - Calculating Speed and Distance
28:57 - Robot Car wiring layout
32:32 - Robot Car Schematic
34:35 - Arduino Sketch for Robot Car
45:35 - Robot Car in Action!
46:52 - Conclusion

There is a lot covered in this video but it actually just scratches the surface of the potential our little Robot Car has. I’m going to keep this car and add to it in future videos so if you want to know when there are updates (such as the much-requested remote control feature) please subscribe to the channel!

Again all of the code is available on the DroneBot Workshop website .

Hope you enjoy the video!

All Comments (21)
  • @CountryNerd639
    I really like watching your videos. You explain the project in a way that I can understand. Most tutorials fly through the steps that some of the information is missing, or glossed over. That is why I appreciate your style of teaching.
  • @ashr
    I learned more about Arduino programming from this video in 40 minutes, then I did in almost 1 semester of my college classes that teaches us to work with the Arduino Uno.
  • Excellent work! You are a great teacher. I found you last week and learn from you things I m looking for months before. Thank you and keep uploading!
  • @tegekgast
    Excellent timing! Just got into this thing and wondered how the heck the speedometer things work, the Chinese instructions aren't much help and you are a hero doing this series in your calm and structured way, much appreciated!
  • @peterbaker6597
    I am teaching myself Arduino and to a smaller extent robotics. I have followed your excellent tutorials about the robot car and every detail is clearly explained and easy to follow. The instructions on Interrupts (and the link to Nick Gammon) made my project jump ahead in leaps and bounds. I did find that the last code would not run until I put a few pinMode(??, OUTPUT) instructions in the setup to define the Arduino to L298N driver pins. Once they were set, away we went. Thanks again and I'm looking forward to your continued additions to the car.
  • @Aegir1001
    A big thank you for a nice and informative tutorial. I was pondering whether to start to learn Arduino and found your channel after a short search. Very interesting - now I'm hooked!
  • @Webendowed
    I'm new to the group and I must say this is great. I'm learning so much and having thought provoking ideas as well. Thank you for these great videos DroneBot Workshop
  • @pastrana2000
    Outstanding video! You really explained things here in layman's terms which helped tremendously.
  • @msignal2000
    Decided to spend the corona lock down learning Arduino. So very glad I found your channel.
  • For some reason, I volunteered to enter a robotics competition for my senior project... extremely thankful for this video
  • My compliments and applause. Simply amazed by such a well structured lesson.
  • @1DR31N
    It cannot be better. What a great video. Words aren't enough to praise your job. Congratulations, you deserve the best.
  • @carlosl1895
    I’m starting with arduino. Still don’t know how to program it. Thank you for such a great explanation. To me is the best video I have seen. Keep up with it
  • @123kkambiz
    Your tutorials are excellent.Thank you very much for uploading the video with excellent camera positioning and video editing.
  • @joerinaldi5
    Excellent Presentation. Clearly explained with complete details of project without any missing steps. Very easy to follow...thanks
  • @eclecticlife
    Excellent instructional video! Your videos are clear, easy to understand, and to the point. Thank you for all the effort and for sharing your knowledge.
  • @VerifiedUser-DE
    The way you explain everything is amazing ..which let me stick till last...waiting for more material ..mostly excited about IOT
  • @hayttom
    Thank you very much! I mainly came here to begin to understand interrupts. I'm on my way!
  • very well done, congratulation. I love the details and the clarity of your explanation. Keep up the good work