|
Mavzu: ultra tovushli masafo datchigi kerakli elemnlar
|
tarix | 28.03.2023 | ölçüsü | 0,49 Mb. | | #103368 |
| 145-20f KERAKLI ELEMNLAR HC-SR04 ultra tovushli masofa datchigi HC-SR04 ultratovushli masofa o‘lchagichning texnik ko‘rsatgichlari: - HC-SR04 ultratovushli masofa o‘lchagichning texnik ko‘rsatgichlari:
- O‘lchanuvchi oraliq - 1 dan 300 sm gacha;
- NISBIY xatoligi - 0,3 sm;
- ko‘rish burchagi - < 15°;
- ma’nba kuchlanishi - 5 V.
- Datchik 4 ta standart chiqishga ega 2,54 mm:
- VCC - +5 V manba;
- Trig (T) – kirish signalining oyoqchasi;
- Echo (R) - chiqish signalining oyoqchasi;
- GND - yer.
Aborotlarni olish uchun harakatlar ketma-ketligi quyidagicha: - Trig karnayi orqali ultratovush tolqinlari yuboriladi
- Echo mikrafonchasi orqali qaytgan tovush tulqini qabul qilinadi
- Tovush ni urilip qaytish uchun ketgan vaqt hisoblanadi,
- Masofa esa Tovush tezligini ketgan vaqtga kupaytirish orqali topiladi
- S=V*t/2 FORMULA ORQALI TOPILADI V =331m/s
Arduno kodi - #include // includes the LiquidCrystal Library LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7) const int trigPin = 9; const int echoPin = 10; long duration; int distanceCm, distanceInch; void setup() { lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); } void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distanceCm= duration*0.034/2; distanceInch = duration*0.0133/2; lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed lcd.print("Distance: "); // Prints string "Distance" on the LCD lcd.print(distanceCm); // Prints the distance value from the sensor lcd.print(" cm"); delay(10); lcd.setCursor(0,1); lcd.print("Distance: "); lcd.print(distanceInch); lcd.print(" inch"); delay(10); }
Dostları ilə paylaş: |
|
|