Yuav Ua Li Cas Thiaj Ua Ultrasonic Rangefinder Ntawm HC-SR04 Thiab Arduino

Cov txheej txheem:

Yuav Ua Li Cas Thiaj Ua Ultrasonic Rangefinder Ntawm HC-SR04 Thiab Arduino
Yuav Ua Li Cas Thiaj Ua Ultrasonic Rangefinder Ntawm HC-SR04 Thiab Arduino

Video: Yuav Ua Li Cas Thiaj Ua Ultrasonic Rangefinder Ntawm HC-SR04 Thiab Arduino

Video: Yuav Ua Li Cas Thiaj Ua Ultrasonic Rangefinder Ntawm HC-SR04 Thiab Arduino
Video: ARDUINO NANO + Ultrasonic sensor HC-SR04 2024, Kaum ib hlis
Anonim

Kuv tshaj tawm txog qhov project rangefinder raws li HC-SR04 ultrasonic sensor thiab Arduino board. Lub sensor nyeem tau tshwm ntawm cov kua siv lead ua zaub, thiab lub zog siv los ntawm ib lub roj teeb hluav taws xob 9 volt.

Cov phiaj xwm rav phiaj xwm
Cov phiaj xwm rav phiaj xwm

Nws yog qhov tsim nyog

  • - Arduino Nano;
  • - ultrasonic rangefinder HC-SR04;
  • - Cov duab LCD;
  • - lub cev;
  • - roj teeb "Krona";
  • - 10 kOhm potentiometer;
  • - khob cij board;
  • - txuas xov hlau.

Cov Lus Qhia

Kauj ruam 1

Txhawm rau pib nrog, koj yuav tsum xaiv qhov loj me rau rooj plaub. Qhov loj yog nyob ntawm seb Arduino board koj yuav siv (UNO, Mini, Nano, lossis lwm tus), nrog rau seb koj lub LCD loj npaum li cas. Nws yog qhov tsim nyog los siv qhov ntsuas me me ntawm LED nrog 3 tus cim hloov ntawm LCD. Qhov no yuav txaus los qhia qhov kev ncua deb hauv centimeters, vim cov ultrasonic sensor siv muaj ntsuas ntau ntawm 3 txog 400 cm.

Xaiv ib rooj ntaub ntawv rau qhov teeb meem sib luag
Xaiv ib rooj ntaub ntawv rau qhov teeb meem sib luag

Kauj ruam 2

Cia peb kwv yees yuav ua li cas cov yam yuav npaj hauv lub cev. Txiav tawm lub qhov rau ultrasonic sensor, rau cov zaub thiab rau on-off hloov.

Kauj ruam 3

Tam sim no cia saib ntawm Circuit Court ntawm peb lub cuab yeej. Fais fab mov - los ntawm roj teeb "Krona" 9 V. Toggle hloov S1 - txhawm rau qhib lub ntaus ntawv thiab tua. Cov kua siv lead ua kua (LCD) tau txuas nrog txoj hauv kev uas muaj 10 kΩ potentiometer los kho qhov txawv. LCD thiab ultrasonic sensor tau siv los ntawm 5 V.

Ultrasonic rangefinder Circuit Court
Ultrasonic rangefinder Circuit Court

Kauj ruam 4

Cia peb sau cov duab kos rau peb cov rangefinder. Txhua yam yog yooj yim ntawm no. Ua ntej, peb pib lub LCD ntawm pins 12, 11, 10, 9, 8 thiab 7 siv LiquidCrystal lub tsev qiv ntawv los ntawm Arduino IDE.

Tom ntej no, peb txuas qhov txhais thiab ncha pins ntawm qhov kev txwv rau cov koob 6 thiab 5 ntawm Arduino board.

Txhua txhua 50 ms peb yuav thov kom qhov kev nyob nrug deb ntawm tus ntsuas uas siv lub muaj nuj nqi getDistance () thiab tso rau ntawm LCD.

Kwv txhiaj plev
Kwv txhiaj plev

Kauj ruam 5

Tom qab peb tau sau cov duab kos rau Arduino lub cim xeeb, peb tuaj yeem sib sau ua ke cov khoom siv. Lub txheej ntawm cov haujlwm hauv kuv hais qhia hauv daim duab. Kuv kho cov zaub thiab sensor nrog kub yaj kua nplaum. Nws tuas nruj, tab sis tib lub sijhawm ua rau nws tuaj yeem tshem tawm cov khoom sib txuas, yog tias tsim nyog. Nws raug nquahu kom tso txhua yam kom koj tuaj yeem txuas rau USB chaw nres nkoj ntawm Arduino thiab kho qhov "firmware" yog tias tsim nyog. Piv txwv li, hloov cov ntawv tso tawm kom pom lossis kho cov coefficients rau xam qhov nrug. Nws kuj yuav tsim nyog hloov pauv qhov sib piv ntawm LCD, yog li nws tseem yuav tsum tau ua kom muaj lub zog ntawm potentiometer txuas.

Qhov txheej txheem ntawm sab hauv ntawm ultrasonic rangefinder
Qhov txheej txheem ntawm sab hauv ntawm ultrasonic rangefinder

Kauj ruam 6

Ib qho version ntawm cov khoom tiav tiav tau pom hauv daim duab. Nws yog qhov haum thiab siv tau yooj yim. Yog lawm, cov cuab yeej siv no muaj nws tus kheej cov yam ntxwv. Ntau cov lus qhia tseem ceeb muaj nyob rau tom kawg hauv ntu lus qhia muaj txiaj ntsig zoo.

Pom zoo: