هنر
زیبایی و سلامت
صنایع دستی
فرهنگ و تاریخ
سرگرمی
محیط زیست
غذا و نوشیدنی
مهندسی معکوس
علوم
ورزش
فناوری
پوشیدنی‌ها
Building an Ultrasonic Parking Sensor
Ed

ایجاد شده توسط

Ed

13. ژوئیه 2026FI
۵۶
۰
۰
۰
۰

Building an Ultrasonic Parking Sensor

Measure distance with sound. An HC-SR04 ultrasonic sensor sends out a pulse of sound and times its echo, and the Arduino turns that into a distance in centimetres. Wire it to a buzzer that beeps faster as something gets closer — a car parking sensor, a reversing aid, or a doorway proximity alarm.

مبتدی
1 hour

دستورالعمل‌ها

1

Wire the sensor and buzzer

Push the HC-SR04 and the active buzzer into the breadboard. Wire the sensor: VCC to Arduino 5V, GND to GND, Trig to pin 9, Echo to pin 10. Wire the buzzer: + to pin 8, - to GND.

مواد مورد نیاز این مرحله:

Arduino Uno R3Arduino Uno R31 قطعه
HC-SR04 Ultrasonic Distance Sensor (5-Pack)HC-SR04 Ultrasonic Distance Sensor (5-Pack)1 قطعه
ماژول بازر فعالماژول بازر فعال1 قطعه
بردبوردبردبورد1 قطعه
سیم رابطسیم رابط1 بسته
2

Connect and open the IDE

Plug the Arduino into your computer with the USB cable, open the Arduino IDE, and select Arduino Uno and its serial port.

ابزارهای مورد نیاز:

رایانه با Arduino IDEرایانه با Arduino IDE
کابل USB-Bکابل USB-B
3

Upload the parking-sensor sketch

Paste this sketch and upload. It measures the distance and beeps faster the closer an object is. Open the Serial Monitor to see the distance in centimetres.

ultrasonic_parking_sensor.inoarduino
// Ultrasonic parking sensor: the buzzer beeps faster as an object gets closer.
// HC-SR04 Trig on pin 9, Echo on pin 10; active buzzer on pin 8.

const int TRIG_PIN = 9;
const int ECHO_PIN = 10;
const int BUZZER_PIN = 8;

void setup() {
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // send a short trigger pulse
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  // time the echo and convert to centimetres (speed of sound ~343 m/s)
  long duration = pulseIn(ECHO_PIN, HIGH);
  int distance = duration * 0.0343 / 2;

  Serial.print(distance);
  Serial.println(" cm");

  if (distance > 0 && distance < 50) {
    int gap = distance * 6;          // closer = shorter gap between beeps
    digitalWrite(BUZZER_PIN, HIGH);
    delay(30);
    digitalWrite(BUZZER_PIN, LOW);
    delay(gap);
  } else {
    digitalWrite(BUZZER_PIN, LOW);   // nothing close -> silent
    delay(60);
  }
}
4

Test and set the range

Move your hand toward the sensor — the buzzer beeps faster as you get closer and nearly solid when very near. Change the 50 in the sketch to set how far away it starts reacting, and the * 6 to change how quickly the beeping speeds up.

5

Mount it

Fix the sensor facing outward on a bracket or in a small box and power the Arduino from a USB power bank or a 9 V adapter. Aim it at your parking spot, garage wall or doorway.

مواد

5
  • 1 قطعه
    1 vendor sell this, none ship to you yet
    جایگزین
  • Ultrasonic Sensor - HC-SR0410% کمیسیون
    1 قطعه
    $4.25
  • جایگزین
  • 1 قطعه
    1 vendor sell this, none ship to you yet
    جایگزین
  • 1 بسته
    3 vendors sell this, none ship to you yet
    جایگزین

ابزارهای لازم

3
  • جایگزین
  • 1 vendor sell this, none ship to you yet
    جایگزین
  • 1 vendor sell this, none ship to you yet
    جایگزین
مجموع تخمینی
آنچه سازنده خریده است. موادی که بدون قیمت نشان داده شده‌اند را از هر جا که بخرید تهیه می‌کنید.
$4.25

این نقشه می‌سازد

نقشه‌های مرتبط

این نقشه‌ها دانش مشترکی دارند — تکنیک‌ها، مواد یا اصول

CC0 مالکیت عمومی

این نقشه تحت مجوز CC0 منتشر شده است. شما آزاد هستید آن را کپی، ویرایش، توزیع و برای هر هدفی بدون نیاز به اجازه استفاده کنید.

با خرید محصولات از طریق نقشه از سازنده حمایت کنید و او کمیسیون سازنده تعیین شده توسط فروشندگان، دریافت می‌کند یا یک نسخه جدید از این نقشه ایجاد کنید و آن را به عنوان اتصال در نقشه خود قرار دهید تا درآمد به اشتراک گذاشته شود.

بحث و گفتگو

(0)

ورود برای شرکت در بحث

در حال بارگذاری نظرات...