Arduino Robot Car with Speed Sensors - Using Arduino Interrupts

preview_player
Показать описание
Let's build a robot car that uses those slotted "optical speed sensors"! We'll also learn about Arduino Interrupts.

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!
Рекомендации по теме
Комментарии
Автор

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.

ashr
Автор

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.

CountryNerd
Автор

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!

tegekgast
Автор

Just a little note. Any variable that will be changed by interrupts should be defined as "volatile". So, counter1 and counter2 should be defined as volatile.

cemox
Автор

Decided to spend the corona lock down learning Arduino. So very glad I found your channel.

msignal
Автор

For some reason, I volunteered to enter a robotics competition for my senior project... extremely thankful for this video

charlesbrown
Автор

Great video.

Your > is "greater than" not less than... You said it correctly towards the end, but it was confusing when you said it incorrectly while explaining the logic of your functions. Excellent demonstration though on the use of optical sensors, comparators and interrupts. Great stuff!

bluehornet
Автор

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

carlosl
Автор

Thank you very much! I mainly came here to begin to understand interrupts. I'm on my way!

hayttom
Автор

hi and thank you for this work, it's a great start for me.

Some improvements I did in the move routines code:
1. if you use "II" instead "&&" in "while", then the movement finish when both motors end at the same number of steps.
2. instead of "steps > counter_A" I use "counter_B >= counter_A" and instead of "steps > counter_B" i use "counter_A >= counter_B".. in this case each motor waits the other to complete same number of steps, so the movement is straight.

andreaszervas
Автор

You should make a video on building a drone with a camera attached. Just a thought! You just explain things so well it would make things so much easier for my brain to crunch on.

dbbi
Автор

It cannot be better. What a great video. Words aren't enough to praise your job. Congratulations, you deserve the best.

DRN
Автор

This video is worth every minute watching, you made such a fine job, Thank you!

andur
Автор

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.

peterbaker
Автор

The way you explain everything is amazing ..which let me stick till last...waiting for more material ..mostly excited about IOT

VerifiedUser-DE
Автор

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

Webendowed
Автор

Just a few short comments. First, please note that 25.4 cm is NOT "about a foot." It actually is 10 inches.

Second, while I enjoyed your video, as I always do, I came here looking for a way to control SPEED of two motors so they track accurately together. After all, the encoder disk is referred to as a "speed sensor". The motors you used, quite visibly, do NOT both turn at the same rpm, as the car drifted to one side when it moved. That was also obvious during your first demonstration showing rpm on the Serial Monitor. The two numbers were not in sync. If you do not have a video that addresses this issue, please consider making one.

Thank you for your time and efforts producing these videos. I enjoy them and have learned a lot from you. Keep it up.

Finally, to those who comment on your (and others') videos with lines like "I have a project due Monday, how can I do..." These drive me mad, as it seems they want YOU to do the work and let tham take credit for it to get their diploma/degree. Instead, I recommend those people actually invest in LEARNING something, instead of poaching others' work. Grrrr...

timrobinson
Автор

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!

andreaszervas
Автор

Another way I found to make it go straight is using a compass and following a heading, so if something interferes with the robot it wil autocorrect and using encoders too he can know the distance .

neurosp
Автор

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.

eclecticlife