Arduino Robot Car with Speed Sensors - Using Arduino Interrupts
DroneBot Workshop
View ChannelAbout
Welcome to the Workshop! The DroneBot Workshop is the place where I work with Arduino, Raspberry Pi, ESP32, and lots of other cool microcontrollers, components, and sensors. This is a channel for learning and understanding. While I do build projects, most episodes focus on showing you HOW things work, so you can use the information to bring your own designs to life. Every video has a corresponding article on my website at https://dronebotworkshop.com , along with the diagrams and code samples you’ll need to build your own creations. You can also participate in discussions on my Forum at https://forum.dronebotworkshop.com. Please note that I no longer do any sponsored videos, enquiries for these will be ignored! If you'd like to know more about me or the DroneBot Workshop you can read the FAQ at https://dronebotworkshop.com/about-dronebot-workshop/faq/ And if you have technical questions please ask them on the Forum. Welcome to the Workshop! I hope you enjoy your stay! Bill
Latest Posts
Video Description
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 https://dronebotworkshop.com/robot-car-with-speed-sensors/ More articles and tutorials: https://dronebotworkshop.com Join the conversation on the forum: https://forum.dronebotworkshop.com Subscribe to the newsletter and stay in touch:https://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!
Essential iPhone 14 Plus Accessories
AI-recommended products based on this video

for Magsafe Car Mount【20 Strong Magnets 】Magnetic Phone Holder for Car Phone Holder Mount Dash【360°】Cell Phone Mount for Car Accessories,Car Mount for iPhone 16 Pro Max 15 14 13 12 Plus MagSafe Cases

Magnetic Wireless Charger for iPhone - 3 in 1 Mag-Safe Charging Station for Multiple Devices Apple - Charger Stand Dock for Apple Watch iPhone 16 15 14 13 12 Pro Max Plus Airpods

4-in-1 Wireless Magnetic Power Bank 10800mAh Portable Charger with iWatch Charger, QC4.0+20W PD Fast Charging USB C Battery Pack for Magsafe, iPhone 16/15/14/13/12 Series, Apple Watch etc. (White)

eazpower for Magsafe Power Bank 10000mAh, Magnetic Battery Pack Wireless, 20W PD Fast Charging, Compact Portable Charger with Built-in Cables and Stand for iPhone 16/15/14/13/12/ Apple Watch/Airpods

Wireless Charging Case for AirPods Pro 1st / 2nd Gen with Type-C Charging Port, Compatible with AirPod Pro 2nd Generation Replacement Case, with Blue-Tooth Sync Button, No Earbuds
![Anker USB C Cable, [2-Pack, 6 ft] Type C Charger Premium Nylon USB Cable, USB A to Type C Charging Cable Fast Charge for Samsung Galaxy S10 S10+ / Note 8, LG V20 and Other USB C Charger (Black)](https://m.media-amazon.com/images/I/71N7xhCJnoL._AC_UL960_FMwebp_QL65_.jpg)
Anker USB C Cable, [2-Pack, 6 ft] Type C Charger Premium Nylon USB Cable, USB A to Type C Charging Cable Fast Charge for Samsung Galaxy S10 S10+ / Note 8, LG V20 and Other USB C Charger (Black)

Anker USB C Charger Cable (6ft 100W, 2Pack), USB 2.0 Type C Fast Charging Cable for iPhone 15 / 15Pro / 15Plus / 15ProMax MacBook Pro 2020, iPad Pro 2020, iPad Air 4, Samsung Galaxy S23+/S23 Ultra ClimatePartner certified
![Spigen Spigen Tempered Glass Screen Protector [GlasTR EZ FIT] designed for Nintendo Switch 2 (2025) - 2 Pack](https://m.media-amazon.com/images/I/61L0hIGSbYL._AC_UL1500_FMwebp_QL65_.jpg)
Spigen Spigen Tempered Glass Screen Protector [GlasTR EZ FIT] designed for Nintendo Switch 2 (2025) - 2 Pack

UGREEN USB to USB C Adapter & USB C to USB Adapter Combo 4-Pack, 10Gbps Type-C Converter, Car Charger Compatible with MacBook Pro, iPad Mac mini, iPhone 17/16, Galaxy, PC/Laptop, Hard Drive Enclosure

USB C Car Charger, 3-Port 67W Super Fast Charging Dual USB-C & USB-A Car Charger Accessories Cigarette Lighter Adapter for iPhone 17 16e 16 15 14 13 12 11 Pro Max, iPad, Galaxy, Pixel, Android Phone

USB C Car Charger 121W, IDOLCO 2-Port Car Charger USB C Fast Charger PD3.0 QC4.0 PPS Fast Charging 12V Car Phone Charger Cigarette Lighter Adapter Plug for iPhone 16/15/14 Series, Galaxy S24/MacBook

URVNS 240W USB C Car Charger, Super Fast Charging 4-Ports PD3.1 140W/PD3.0 100W PPS 45W QC65W Type-C Car Adapter for MacBook Pro Laptop iPhone 15 14 Max iPad Samsung Galaxy S24/23/22 Pixel etc
![VANMASS [85+LBS Strongest Suction & Clip] 2025 Upgrade Car Phone Holder [Patent & Safety Certs] Cell Phone Mount Truck Stand for Dashboard Windshield Vent for iPhone 16 Pro Max 15 14 13 12 Samsung](https://m.media-amazon.com/images/I/71bHSP1cRkL._AC_UL960_FMwebp_QL65_.jpg)
VANMASS [85+LBS Strongest Suction & Clip] 2025 Upgrade Car Phone Holder [Patent & Safety Certs] Cell Phone Mount Truck Stand for Dashboard Windshield Vent for iPhone 16 Pro Max 15 14 13 12 Samsung

Magnetic Car Mount Air Vent Cell Phone Holder, Universal Vehicle Dash Dashboard Ac Airvent Cellphone Magic Stand with Clip Hook, for iPhone 16 15 Samsung Lenovo Google etc
![Miracase Car Phone Mount, [2025 Upgraded Strong Military Grade Suction Cup] Long Arm Phone Holder for Car Dashboard Windshield Vent, Hands Free Cell Phone Holder Compatible with All Mobile Phones Global Recycled Standard](https://m.media-amazon.com/images/I/81oehGW5OLL._AC_UL960_FMwebp_QL65_.jpg)
Miracase Car Phone Mount, [2025 Upgraded Strong Military Grade Suction Cup] Long Arm Phone Holder for Car Dashboard Windshield Vent, Hands Free Cell Phone Holder Compatible with All Mobile Phones Global Recycled Standard

Apple AirPods Pro 2 Wireless Earbuds, Bluetooth Headphones, Active Noise Cancellation, Transparency, Personalized Spatial Audio, High-Fidelity Sound, H2 Chip, USB-C Charging

Google Pixel Buds Pro 2 - Noise Canceling Earbuds - Up to 31 Hour Battery Life with Charging Case - Bluetooth Headphones - Compatible with Android - Hazel

Beats Fit Pro - True Wireless Noise Cancelling Earbuds - Active Noise Cancelling - Sweat Resistant Earphones, Compatible with Apple & Android, Class 1 Bluetooth®, Built-in Microphone - Beats White

Wireless Charging Case for AirPods Pro 1st / 2nd Gen with Type-C Charging Port, Compatible with AirPod Pro 2nd Generation Replacement Case, with Blue-Tooth Sync Button, No Earbuds
![Spigen Case for Galaxy S25 Case, Rugged Armor MagFit [Fast Wireless Charging] Compatible with MagSafe - Black](https://m.media-amazon.com/images/I/81osE87mFrL._AC_UL960_FMwebp_QL65_.jpg)
Spigen Case for Galaxy S25 Case, Rugged Armor MagFit [Fast Wireless Charging] Compatible with MagSafe - Black
![Vihibii for Samsung Galaxy S25+ Plus Wallet Case with Card Holder (4 Cards) [RFID Blocking] & Slide Camera Cover & Raised Edges Protect Screen, Shockproof Rugged Case for S25+ Plus 6.7" 2025, Black](https://m.media-amazon.com/images/I/71YSDNV+PHL._AC_UL960_FMwebp_QL65_.jpg)
Vihibii for Samsung Galaxy S25+ Plus Wallet Case with Card Holder (4 Cards) [RFID Blocking] & Slide Camera Cover & Raised Edges Protect Screen, Shockproof Rugged Case for S25+ Plus 6.7" 2025, Black
![Vihibii for Samsung Galaxy S25+ Plus Wallet Case with Card Holder (4 Cards) [RFID Blocking] & Slide Camera Cover & Raised Edges Protection, Shockproof Rugged Case for S25+ Plus 6.7" 2025, Hot Pink](https://m.media-amazon.com/images/I/71K-GtDw48L._AC_UL960_FMwebp_QL65_.jpg)
Vihibii for Samsung Galaxy S25+ Plus Wallet Case with Card Holder (4 Cards) [RFID Blocking] & Slide Camera Cover & Raised Edges Protection, Shockproof Rugged Case for S25+ Plus 6.7" 2025, Hot Pink
![Spigen Case for iPhone 16 Pro Max Case, Rugged Armor [MagFit] Compatible with MagSafe - Matte Black](https://m.media-amazon.com/images/I/71Gh0VOQtlL._AC_UL960_FMwebp_QL65_.jpg)



