MoonCampaign by Praneel (10 years)
Our Social Impact - We're transforming education globally with free robotics and math workshops in the US, UK,
Canada, and Australia.
Our workshops have helped 66,000 students alone in the US plus 14,000 students benefit from our four-week sessions.
Ultrasonic Sensor
Show and Tell
Show n Tell
Coming Soon
Praneel’s Ultrasonic Sensor project turns the Arduino Uno into a dodging robot for a teen learning to code. An ultrasonic sensor spots obstacles, wheels roll to steer clear, and it’s a thrilling way to build a mini autonomous bot with coding.
I was racing my toy cars and wanted to make one that avoids crashes by itself, so I built my Ultrasonic Sensor project with my Arduino Uno—my first coding try! I used a sensor to see things in the way and wheels to move my robot around them, like a smart little racer. It’s so cool watching it dodge stuff like a real autonomous bot!
I wired an HC-SR04 ultrasonic sensor to pins 6 (trigger) and 7 (echo), and hooked up a motor driver (like an L298N) to pins 9 and 10 for two wheels. In void setup(), I set pinMode(6, OUTPUT), pinMode(7, INPUT), and motor pins as OUTPUT. In void loop(), the sensor pings—digitalWrite(6, HIGH), delayMicroseconds(10), duration = pulseIn(7, HIGH)—and calculates distance with distance = duration * 0.034 / 2. If something’s close—if (distance < 20)—the wheels stop with digitalWrite(9, LOW) and digitalWrite(10, LOW), then turn left by running one motor. If it’s clear, it rolls forward. The robot spun wildly at first, but I tweaked the motor timing with delay(500), and now I cheer when it swerves around my toy cars!
I’m stoked to make it slicker next time! Maybe I’ll add a buzzer to beep when it stops, or make it back up before turning. I could even give it LEDs to flash like a race car! I really like coding this with my Arduino, and I can’t wait to race my friends’ robots and see who dodges best!
Future applications for this project could be epic! I could turn it into a tiny delivery bot that drops off snacks without bumping tables, like the tiling robots you mentioned. Or maybe a vacuum cleaner bot that maps my room, or a patrol droid that guards my desk, making my gadgets as smart as SAM the brick-laying robot!
©️ Copyright, Moonpreneur Inc.
3031 Tisch Way, 110 Plaza West PMB # 138, San Jose, CA 95128, USA
Likes
Rating
22 days left
Ultrasonic Sensor