Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

Ultrasonic Distance Indicator | LED Visual Alert System Easy DIY Project

   

Ultrasonic Distance Indicator | LED Visual Alert System Easy DIY Project 

That sounds like a fun project! Here's how you can create it:

Components Needed:

  1. Arduino Board (e.g., Uno, Nano)
  2. Ultrasonic Sensor (e.g., HC-SR04)
  3. 10 LEDs
  4. 10 Resistors (220Ω recommended for each LED)
  5. Breadboard and Jumper Wires

Concept:

You'll divide the distance detected by the ultrasonic sensor into 10 ranges. Each range will correspond to a specific LED being lit. For example, if the distance is between 0-10 cm, 1 LED will be on; if it's between 10-20 cm, 2 LEDs will be on, and so forth.

Circuit Diagram:

  1. Ultrasonic Sensor:
    • VCC to 5V on Arduino
    • GND to GND on Arduino
    • Trig to a digital pin (e.g., Pin 9)
    • Echo to a digital pin (e.g., Pin 8)
  2. LEDs:
    • Connect the cathode (-) of each LED to GND through a 220Ω resistor.
    • Connect the anode (+) of each LED to a digital pin on the Arduino (e.g., Pins 2-11).

Video Link: - Click Here For Video

Ultrasonic Distance Indicator simple Circuit: -





Ultrasonic Distance Indicator Arduino Programming: -

Arduino IDE Program

const int trigPin = 9; const int echoPin = 8; const int ledPins[10] = {2, 3, 4, 5, 6, 7, 10, 11, 12, 13}; void setup() { // Set up the LED pins for (int i = 0; i < 10; i++) { pinMode(ledPins[i], OUTPUT); } // Set up the ultrasonic sensor pins pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); // Start the serial communication Serial.begin(9600); } void loop() { // Measure the distance long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = duration * 0.034 / 2; // Calculate the number of LEDs to light up int numLEDs = map(distance, 0, 100, 0, 10); // Turn on LEDs according to the distance for (int i = 0; i < 10; i++) { if (i < numLEDs) { digitalWrite(ledPins[i], HIGH); } else { digitalWrite(ledPins[i], LOW); } } // Print the distance for debugging Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm"); delay(100); }

-----------------------------------------------------------------------------------------------------------------------------

Explanation:

  • Trig Pin sends an ultrasonic pulse.
  • Echo Pin receives the pulse that bounces back.
  • The distance is calculated based on the time it takes for the pulse to return.
  • The map() function converts the distance (from 0 to 100 cm) into a range from 0 to 10 LEDs.

Assembly:

  1. Build the circuit on the breadboard.
  2. Upload the code to your Arduino board.
  3. Test by placing objects at various distances from the ultrasonic sensor and observe the number of LEDs that light up.

Let me know if you need any adjustments or further help!

Share, Support, and Subscribe!!! 1. PRO KAM EXPLAINED 2. Knowledge KAM 3. PRO KAM Follow us on 1. Facebook 2. Instagram 3. Pinterest 4. Blogspot 5 Twitter If you have any other ideas to make me design, you can describe them in the comment section and if I can, I will make a designing video on it. So I am waiting #prokam #pro #IDM #Solutions #Hack

Post a Comment

0 Comments

Ad Code

Responsive Advertisement