This Little Robot Hates Bumping Into Stuff (And You Can Build It)

Picture this: your robot glides across the floor, heads straight for a chair leg… and at the very last second, it swerves away like it knew the future. No crashes, no drama, just a smooth little dodge. That’s the magic of obstacle avoidance, and you can actually build it yourself. A lot of students think you need advanced math or fancy lab gear to get into robotics. You really don’t. With a simple microcontroller, a few sensors, and some patience, you can create a robot that “sees” what’s in front of it and decides where to go next. It’s basically teaching a shoebox on wheels how not to embarrass itself. In this guide, we’ll walk through how to design a basic obstacle‑avoiding robot that’s perfect for a science fair project. We’ll talk about parts, wiring, the logic behind the code, and even how to present it so judges actually remember you. If you can follow a recipe and plug in a phone charger, you’re already qualified to start. Let’s turn that pile of parts into something that can navigate your living room without wiping out.
Written by
Taylor
Published

Why build a robot that refuses to crash?

If you think about it, almost every useful robot has to deal with the same annoying problem: the world is full of stuff. Walls, chairs, backpacks on the floor, your dog… A robot that just drives straight until it hits something isn’t very helpful.

Self‑driving cars, warehouse robots, even tiny vacuum robots all rely on obstacle avoidance. When you build a small version for your science fair, you’re basically creating a mini‑lab for the same ideas big tech companies are obsessed with.

There’s also a very practical reason: a moving robot that reacts to its surroundings looks impressive. It’s noisy (in a good way), it has lights, it moves, and it looks like it’s “thinking.” Judges remember that.

So what does an obstacle‑avoiding robot actually need?

You don’t need a suitcase of electronics. At the core, you’re building four things:

  • A body so everything has somewhere to live
  • A brain to make decisions
  • Sensors to detect obstacles
  • Motors and wheels to move and turn

Think of it like a human:

  • The chassis is the skeleton.
  • The microcontroller is the brain.
  • The sensors are the eyes.
  • The motors are the muscles.

Once you see it that way, the whole thing feels a lot less scary.

The chassis: more than just a pretty base

You can absolutely buy a pre‑made two‑wheel robot chassis online. But if you’re into DIY, cardboard and hot glue can actually take you pretty far. One student, Maya, showed up at her fair with a robot built on a cut‑up cereal box. It wasn’t fancy, but it worked beautifully, and the judges loved that she’d improvised.

When you’re planning the body, think about:

  • Weight: Too heavy, and your motors will struggle. Too flimsy, and it falls apart.
  • Balance: Two drive wheels and a small caster wheel or even a smooth plastic slider at the back works well.
  • Space: Leave room on top for your microcontroller board, battery, and sensor.

If you’re using a kit chassis, you’re mostly just assembling. If you’re building from scratch, it’s basically a craft project with a purpose.

The brain: choosing a microcontroller

For a science fair project, an Arduino Uno or similar board is a sweet spot: cheap, easy to program, and a ton of tutorials exist. A small single‑board computer like a Raspberry Pi is fun but honestly overkill for basic obstacle avoidance.

What your “brain” needs to do:

  • Read data from the sensor ("Is there something in front of me?")
  • Decide what to do ("Keep going” or “Turn away")
  • Tell the motors how to move

If you’ve never coded before, Arduino’s C‑style language is actually not that scary. You’ll mostly be reading values, comparing them to a distance threshold, and switching motor directions.

How does the robot know something’s in the way?

Here’s where it gets interesting. Your robot doesn’t see like you do. It measures.

Two common options for beginners:

  • Ultrasonic distance sensor (like the HC‑SR04)
  • Infrared (IR) proximity sensor

The ultrasonic one works a bit like a bat: it sends out a sound wave you can’t hear and measures how long it takes to bounce back. The shorter the time, the closer the obstacle.

The basic idea looks like this in plain language:

If distance to the obstacle is less than, say, 8 inches, stop and turn. If it’s more, keep going.

You’re turning a continuous world (lots of possible distances) into a simple choice: safe vs not safe.

A simple behavior that feels smart

Imagine your robot driving forward in an open hallway. It’s happy. Then it gets close to a wall. Your code might say:

  • If distance > 8 inches → drive forward
  • If distance ≤ 8 inches → stop, back up a little, then turn right

That’s it. No advanced math, no AI. But when you watch it move, it looks like it “knows” what it’s doing.

One student, Leo, added a little twist: if the robot hit an obstacle on the right side, it turned left instead, and vice versa. It was just a couple of extra lines of code, but it made the behavior look a lot more intentional.

Planning your build like a mini engineering project

Before you grab a screwdriver, it helps to sketch out your plan.

You can think in three phases:

  1. Mechanical – Build the body, mount the motors, attach the wheels.
  2. Electrical – Wire the motors, sensor, and power to the microcontroller.
  3. Software – Write and upload the code, then test and tweak.

You don’t have to draw a technical blueprint. A simple top‑down sketch with boxes for “Arduino,” “battery,” “sensor” and arrows for wires is already helpful. It also looks good on a science fair poster as “Design Plan.”

Mechanical build: getting it rolling

Start with the chassis and motors:

  • Attach the two DC motors or geared motors to the sides.
  • Add wheels that fit your motor shafts.
  • Mount a small caster wheel or smooth support at the back.

Then place your microcontroller board on top, somewhere near the center. The battery pack can go toward the back to balance the weight.

The ultrasonic sensor usually sits on the front like a pair of eyes. That’s not just cute; it actually gives it the best view of what’s ahead.

Electrical connections: the part that looks scary (but isn’t)

This is where a simple wiring diagram is your best friend. Most beginner robot kits come with one. If you’re building from scratch, you can find similar diagrams on university robotics pages like MIT’s introductory robotics materials and adapt them.

You’ll typically have:

  • Motor wires going into a motor driver board (this lets the low‑power Arduino control higher‑power motors).
  • Motor driver connected to Arduino control pins.
  • Sensor connected to Arduino power (5V and GND) and a couple of signal pins.
  • Battery pack connected to the motor driver and/or Arduino (depending on your setup).

Check each connection twice. Most students who say, “My robot doesn’t work!” actually have one wire in the wrong place or a loose jumper cable.

Teaching your robot how to “think” with code

Now the fun part: behavior.

In Arduino code, the pattern is always the same:

  • setup() – runs once at the beginning. You set pin modes and start the sensor.
  • loop() – runs over and over. You read the sensor and control the motors.

The logic in your loop might be:

  1. Measure distance.
  2. If the distance is safe, move forward.
  3. If the distance is too small, stop, back up, then turn.

You can start ridiculously simple. One student, Aisha, began with just two behaviors: go forward and stop. Once that worked, she added backing up. Then she added turning. Step by step, no drama.

If you get stuck, many universities publish basic robotics code examples in their open courseware. For instance, Carnegie Mellon’s Robotics Academy has beginner‑friendly resources that can help you understand the logic, even if you don’t copy their exact code.

Testing: where your robot shows its personality

Testing is where your robot stops being a pile of parts and starts being a character.

Start on a clear floor with no obstacles. Confirm that it drives straight. If it curves to one side, your motors might not match perfectly. You can fix that in code by slightly slowing down the faster motor.

Then add one obstacle, like a shoebox.

Watch what happens:

  • Does the robot react too late and bump into it? Lower your distance threshold.
  • Does it panic and turn away too early? Raise the threshold.
  • Does it get stuck turning in circles? You might need to add a timer so it doesn’t over‑turn.

One group of students turned testing into a game: they built a mini maze out of books and tried to see how far the robot could get without help. Every time it failed, they changed one thing—either in hardware or software—and tried again.

Turning this into a strong science fair project

Let’s be honest: judges have seen “robot car” projects before. So how do you make yours stand out?

You lean into the science part, not just the “I built a cool gadget” part.

Here are angles that work well:

  • Experiment with distance thresholds: How does changing the detection distance affect how often the robot hits obstacles?
  • Compare sensor types: If you can, test ultrasonic vs IR sensors. Which works better on shiny surfaces? Dark surfaces?
  • Measure success: Set up a simple course and count how many collisions happen in 10 runs with different settings.

Suddenly you’re not just showing a toy—you’re running controlled experiments.

Presenting your process like a scientist

On your display board, think in terms of a story:

  • The problem: “Robots need to move around real spaces without crashing. How can a simple robot detect and avoid obstacles?”
  • Your idea: “Use distance sensors and simple rules to control movement.”
  • Your build: Photos of your chassis, wiring, and code.
  • Your tests: Charts or tables showing collision counts at different distance thresholds.
  • Your conclusion: What worked best, what you’d change next time.

Judges love seeing that you tried things that didn’t work at first. If your robot originally spun in place like it was dizzy, mention it. Explain what you changed and what you learned.

Common headaches (and how to calm them down)

A few problems show up again and again:

The robot doesn’t move at all.

Check power first. Are the batteries fresh? Is the switch on? Then check grounds: all parts should share a common ground wire.

The sensor always reads zero or nonsense.

Make sure you connected the echo/trigger (for ultrasonic) or signal pins correctly. Double‑check your code’s pin numbers match the wiring.

The robot sees obstacles that aren’t there.

Ultrasonic sensors can bounce off weird surfaces or edges. Try moving the sensor slightly, or add a small “dead zone” in your code where readings below a certain tiny value are ignored.

If you want to dig deeper into how sensors and simple robots are used in real research and education, sites like NASA’s robotics education pages and Carnegie Mellon’s Robotics Academy are great places to explore.

Where you could take this next

Once you have a basic obstacle‑avoiding robot, you’ve opened a door.

You could:

  • Add line‑following so it stays on a track.
  • Use multiple sensors (front, left, right) so it chooses the best path.
  • Add LEDs or a small speaker so it “reacts” when it sees something.

You’re basically teaching your robot more and more rules about how to live in your house without causing chaos. Which, honestly, is not that different from raising a puppy.

And if you’re wondering whether this kind of project actually matters in the real world: it does. The same basic ideas—sense, decide, act—show up in everything from Mars rovers to factory robots. You’re just learning it at kitchen‑table scale.

FAQ: quick answers before you grab the soldering iron

Do I need to know how to code before starting?

No. You’ll learn enough as you go. Start with example code from Arduino’s official documentation or a trusted tutorial, then tweak it. Understanding what the code is doing is more important than writing everything from scratch on day one.

How long does a project like this usually take?

If you work a couple of hours a day, many students get a basic obstacle‑avoiding robot working in about one to two weeks. If you’re also doing experiments and building a display board, give yourself three weeks so you’re not rushing.

Is it safe to build at home?

Yes, as long as you’re sensible. You’re working with low‑voltage batteries, not wall outlets. If you use tools like a hot glue gun or soldering iron, ask an adult to supervise. General safety tips from sites like NIH’s science education pages are worth a quick look.

What grade level is this best for?

It works nicely from middle school through early high school. Younger students can focus more on the building and basic behavior, older students can dive into experiments, data analysis, and maybe even comparing algorithms.

Can I do this as a team project?

Absolutely. In fact, it’s often better that way. One person can focus on wiring, another on coding, another on testing and data. Just make sure everyone can explain every part of the project to the judges.


If you walk into your science fair with a robot that confidently dodges backpacks and chair legs while you explain how and why it works, you’re not just showing a gadget. You’re showing that you understand the thinking behind real‑world robotics. And that’s, well, pretty impressive.

Explore More Robotics Projects

Discover more examples and insights in this category.

View All Robotics Projects