Arduino HC-SR04 + LED





Introduction: Arduino HC-SR04 + LED

In this tutorial, I will show you how you can build a motion-detecting LED using an ultrasonic sensor (HC-SR04). The parts for this build are provided by KumanTech, you can find them in their Arduino UNO Kit.

Step 1: Parts Needed

1 x Arduino board (I'm using an Arduino Uno)

1 x LED (The color doesn't matter)

1 x 220 ohm resistor

1 x Breadboard

1 x Arduino USB Cable

1 x 9V battery with a clip (optional)

6 x Jumper wires

Allchips is an electronics components online service platform, you can buy all the components from them.

Step 2: Positioning the Parts

First, plug in the ultrasonic sensor and the LED on the breadboard. Connect the LED's shorter lead (the cathode) to the GND pin of the sensor. Then, place the resistor in the same row as the LED's longer lead (the anode) so they are connected.

Step 3: Connecting the Parts

Now, you need to plug some wires on the back of the sensor. There are four pins - VCC, TRIG, ECHO and GND. After inserting the wires, you need to make the following connections:

The resistor's end to a digital pin of your choice, just make sure to change it later in the code!

Sensor | Arduino

VCC -> 5V

TRIG -> 5*

ECHO -> 4*


* - Can be connected to any two digital pins of the Arduino, just make sure you change them in the code later!

Step 4: Uploading the Code

Now, you can plug your Arduino to your computer using an USB cable. Open up the Arduino software and upload the code that you can find here. The constants are commented, so you know exactly what they are doing and possibly change them.

Step 5: The Final Result



  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Gluten Free Challenge

    Gluten Free Challenge

We have a be nice policy.
Please be positive and constructive.




what code

I forgot to paste a link to the code. Edited, you can find it in the 4th step :)

How come after I unplug it, and plug it back in, the LED's just blink continuously, even though nothing is in front of the hc-sr04?

Check your connections. Also did it work correctly before unplugging?