Ultrasonic sensor Arduino project showing Arduino Uno, ultrasonic distance sensor, LED circuit, and laptop setup for kids STEM learning and beginner electronics projects.

STEM School Project for Kids - DIY Ultrasonic Sensor Project Using Arduino for Beginners

This article titled "STEM School Project for Kids - DIY Ultrasonic Sensor Project Using Arduino for Beginners" is part of the "Learn Robotics with CYFI" knowledge series by NESTA TOYS.

Article summary: Ever wondered how a car knows there is a wall behind it while reversing? Now your child can build the exact same technology at home! This fun Arduino project for kids uses the CYFI Ultrasonic Distance Sensor to measure distance, light up an LED alarm, and show live readings on screen all in just 30 minutes. No soldering, no experience needed, and perfect for school science fairs and STEM projects. A hands-on build that teaches real robotics skills kids will actually use.

This educational content focuses on coding, robotics, computational thinking, STEM learning, and technology education for students, parents, educators, and schools.

CYFI by NESTA TOYS is a structured learning platform that combines block-based programming, robotics simulations, hands-on activities, and a gradual transition to text-based coding using Python and C++.

What is an Ultrasonic Sensor and Why Should Kids Build One?

Have you ever watched a car reverse and beep faster as it gets closer to a wall? That is an ultrasonic sensor doing its job and with the CYFI Ultrasonic Distance Sensor Module, your child can build exactly the same thing at home!

An ultrasonic sensor works by sending out a sound wave and listening for the echo. The time it takes for the echo to bounce back tells the sensor how far away an object is - no touching, no guessing, just pure science. The CYFI HC-SR04 module can detect objects from as close as 2 cm all the way up to 4 metres, and it weighs less than a 5 rupee coin.

In this project, you will connect the CYFI Ultrasonic Sensor to an Arduino Uno, upload a few lines of code, and build a working distance detector in under 30 minutes. Bring your hand within 10 centimetres and the LED lights up. The exact distance prints live on your laptop screen. No soldering, no prior experience, and everything you need comes inside your CYFI kit.

Why Parents Love This Project - Real Robotics Skills for Kids Age 8 and Above

•    How ultrasonic sound waves are used to measure distance
•    How an Arduino sends and receives signals
•    How to write and upload Arduino code
•    How sensors are used in real-life technology like parking sensors and robots
•    How to read data on the Serial Monitor screen

Parent tip: This project introduces your child to a concept used in self-driving cars, drones, and medical ultrasound equipment. Building it at home makes that technology feel real and exciting!

What is Inside the CYFI Ultrasonic Distance Sensor Kit - Everything Your Child Needs

Everything below is included in your CYFI kit. If you do not have the kit yet, you can pick it up at cyfi.nestatoys.com. Each component is beginner-safe, low-voltage, and designed for kids age 8 and above.

1. CYFI Ultrasonic Distance Sensor Module (HC-SR04)

This is the star of the project. It has two round eyes one sends out a sound pulse (Trig) and one listens for the echo (Echo). It measures distances from 2 cm to 400 cm and works on both 3.3V and 5V. Compact, lightweight, and snap-fit ready.

2. Arduino Uno board

The brain of the build. It sends the pulse, reads the echo, calculates the distance, and controls the LED all from the code your child uploads.

3. LED light (red or any colour)

The visual alarm. It lights up when an object comes within 10 cm of the sensor. The Arduino Uno has a built-in LED at pin 13, so you can test the project without a separate LED if needed.

4. Jumper wires (4 wires)

Short coloured wires that connect the sensor to the Arduino. Use different colours for each pin - it makes checking your wiring much easier.

5. A laptop or computer with a USB cable

Powers the Arduino and runs the free Arduino IDE app where you upload the code and watch live distance readings on screen.

Fun fact: The CYFI Ultrasonic Sensor Module weighs just 4.7 grams - lighter than a 5 rupee coin - yet it can detect objects up to 4 metres away. Small but mighty!

How to Connect the CYFI Ultrasonic Sensor to Arduino? No Soldering, No Experience Needed

Follow the wire connections below carefully. The HC-SR04 sensor has four pins. You need to connect all four to the Arduino. Take your time and double-check each wire before moving on.

Circuit diagram showing CYFI Ultrasonic Distance Sensor Module HC-SR04 connected to Arduino Uno with red LED and resistor — beginner Arduino project for kids

Wire Connections - 4 wires from sensor to Arduino:

Sensor Pin

Arduino Pin

Wire Colour

What it does

VCC

5V

Red

Powers the sensor

Trig

Pin D6

Orange

Sends the ultrasonic sound pulse

Echo

Pin D7

Purple

Listens for the returning echo

GND

GND

Black

Completes the circuit

— (LED)

Pin D13

Green

Lights up when object is within 10 cm

Parent tip: The LED at pin D13 needs a 220 ohm resistor connected in series to protect it. Connect: Arduino D13 → resistor → long leg of LED → short leg of LED → GND.

How Does an Ultrasonic Sensor Detect Objects? The Science Kids Actually Understand

Here is the science behind your build - explained as a simple chain of events. Once you understand this, you will see why ultrasonic sensors are used in everything from parking cameras to hospital scanners!

Step 1 - Arduino sends a sound pulse

The code tells pin D6 (Trig) to go HIGH for just 10 microseconds. That is 0.00001 seconds incredibly fast! This sends an invisible ultrasonic sound wave shooting out from the sensor. You cannot hear it because it is too high-pitched for human ears.

Step 2 - The sound wave bounces off an object

The sound wave travels through the air until it hits something - your hand, a wall, a book. When it hits that object, it bounces back towards the sensor, just like an echo in a cave.

Step 3 - The sensor listens for the echo

Pin D7 (Echo) is listening the whole time. The moment the echo comes back, it goes HIGH. The Arduino uses the pulseIn() command to measure exactly how long Echo was HIGH - this is the travel time of the sound wave.

Step 4 - Arduino calculates the distance

The code uses this formula to calculate distance:

distance = duration x 0.0343 / 2

0.0343 is the speed of sound in cm per microsecond. We divide by 2 because the sound travels to the object AND back, so we only want one-way distance.

Step 5 - LED turns on and distance appears on screen

If the calculated distance is 10 cm or less, the Arduino turns on the LED at pin D13. At the same time, every 300 milliseconds, it prints the exact distance to your laptop screen via the Serial Monitor. Try moving your hand closer and further away and watch the number change in real time!

The Code — Copy This into Arduino IDE:

// Ultrasonic Sensor (HC-SR04) + LED Arduino Code
const int trigPin = 6;
const int echoPin = 7;
const int ledPin  = 13;
long duration;
float distance;
 
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}
 
void loop() {
  // Clear trig pin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
 
  // Send 10 microsecond pulse
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
 
  // Read echo time
  duration = pulseIn(echoPin, HIGH);
 
  // Calculate distance in cm
  distance = duration * 0.0343 / 2;
 
  // Print distance
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
 
  // LED ON if object is closer than 10 cm
  if (distance <= 10) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }
  delay(300);
}

Fun fact: The speed of sound is about 343 metres per second at room temperature. That sounds fast, but light travels about 900,000 times faster! This is why you see lightning before you hear thunder.

How to Use the CYFI Ultrasonic Sensor for a School Science Project or Robotics Fair

This CYFI Ultrasonic Distance Sensor project is perfect for school science exhibitions, STEM assignments, robotics fairs, and holiday builds. Here is exactly what to do from start to finish:

Step 1 - Choose How You Want to Code It

CYFI gives you two ways to bring your project to life:

Option A - Use the CYFI Platform (Recommended for Beginners)

Go to platform.nestatoys.com/play on your laptop. Head to Templates and open the Ultrasonic Distance template - the program is already built for you using coloured drag-and-drop blocks. No typing needed. Click Simulator to test it on screen first, then click Firmware Flash to upload it directly to your CYFI board.

Option B - Use Arduino IDE (For Kids Who Want to Code)

Go to arduino.cc and download the free Arduino IDE app. Paste in the code from Section 5. Connect your Arduino with the USB cable. Go to Tools > Board > Arduino Uno, select the right COM port, and click the Upload button (the arrow icon).

Both options work perfectly with the CYFI Ultrasonic Distance Sensor Module. Start with the CYFI platform if it is your first time, and move to Arduino IDE when you are ready to explore the full code.

Step 2 - See Live Distance on Screen

Once uploaded, open the Serial Monitor in Arduino IDE (Tools > Serial Monitor, baud rate 9600) or watch the Simulator on the CYFI platform. You will see the distance in centimetres updating every 300ms. Hold your hand in front of the sensor and slowly move it closer - watch the number count down in real time!

Step 3 - Test the LED Alarm

Slowly move your hand towards the sensor. When you get within 10 cm, the LED lights up. Pull your hand back past 10 cm and it turns off. That is your proximity alarm working perfectly - the same technology used in real car parking sensors!

Step 4 - Write Your Project Report

A great school project report should include:

  • The problem you are solving - parking sensors, obstacle-avoiding robots, smart distance alarms
  • A list of all components you used and what each one does
  • How the circuit works - use Section 5 above as your explanation
  • Your test results - at what distance did the LED trigger every time?
  • What you would add or change next time to make it even better

What are the other Ideas to make your project even better?

  • Add a buzzer that beeps faster as the object gets closer - just like a real parking sensor!
  • Add an LCD screen to display the distance in large numbers
  • Set up multiple distance thresholds - yellow LED for 20 cm, red LED for 10 cm
  • Mount the sensor on a servo motor that rotates and scans the whole room for objects

Exhibition tip: At your school stall, let visitors hold their hand in front of the sensor and watch the distance number change on screen. Ask them to guess how far away they are before looking. It is a simple trick that gets everyone involved!

This project is part of the CYFI Arduino Beginner Kit. Made for curious kids and hands-on parents.

Back to blog

Leave a comment