This project uses an ultrasonic sensor to measure distances in centimeters and controls a set of LEDs based on those distances. The project is designed for Arduino boards, and you can use it to build simple distance measurement applications, proximity alerts, or object detection systems.
This Arduino project reads distance data from an ultrasonic sensor and activates LEDs according to different distance thresholds. The sensor uses the time taken by sound waves to bounce back from an object to measure the distance.
To build this project, you need the following components:
- Arduino board (e.g., Arduino Uno)
- Ultrasonic sensor (e.g., HC-SR04)
- 3 LEDs (any color)
- 3 resistors (220 ohms recommended for each LED)
- Jumper wires
- Breadboard
Here's the circuit diagram for this project:
To get started, set up your Arduino IDE and ensure your Arduino board is connected to your computer. Follow these steps:
- Install the Arduino IDE.
- Connect your Arduino board to your computer via USB.
- Copy the provided code into the Arduino IDE.
- Verify and upload the code to your Arduino board.
Once you've set up the hardware and uploaded the code, here's how to use the project:
- Power the Arduino board.
- The system measures distance in centimeters and outputs the value to the serial monitor.
- Depending on the distance, different combinations of LEDs will light up.
- If the distance is greater than 15 cm, all LEDs are off.
- If the distance is between 10 and 15 cm, the first LED is on.
- If the distance is between 5 and 10 cm, the first two LEDs are on.
- If the distance is less than 5 cm, all LEDs are on.