Introduction: Arduino HC-SR04 + LED

Picture of 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

Picture of 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

Step 2: Positioning the Parts

Picture of 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

Picture of 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*

GND -> GND

* - 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

Picture of 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

Comments

dmhoke (author)2017-09-25

what code

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

About This Instructable

1,041views

9favorites

License:

Bio: Student, currently studying programming. Interested in Arduino, Raspberry Pi and Electronics in general.
More by Aleksandar Tsvetkov:Raspberry Pi LED BlinkArduino LED Traffic LightRaspberry Pi Headless Setup
Add instructable to: