Cov txheej txheem:

Yuav Siv Piezo Li Cas Tone: Hauv paus: 4 Kauj Ruam (nrog Duab)
Yuav Siv Piezo Li Cas Tone: Hauv paus: 4 Kauj Ruam (nrog Duab)

Video: Yuav Siv Piezo Li Cas Tone: Hauv paus: 4 Kauj Ruam (nrog Duab)

Video: Yuav Siv Piezo Li Cas Tone: Hauv paus: 4 Kauj Ruam (nrog Duab)
Video: hlub tuag nthi karaoke 2024, Kaum ib hlis
Anonim
Yuav Siv Piezo Li Cas Tone: Hauv paus
Yuav Siv Piezo Li Cas Tone: Hauv paus

Nyob zoo txhua tus, Hauv cov lus qhia no, Peb yuav siv Piezo buzzer los tsim cov suab nrov.

Piezo buzzer yog dab tsi?

Piezo yog cov cuab yeej siv hluav taws xob uas tuaj yeem siv ob qho tib si los tsim thiab ntsuas lub suab

Cov ntawv thov:

  • Koj tuaj yeem siv tib lub Circuit los ua suab paj nruag los ntawm kev hloov Piezo rau thiab tawm ntau zaus.
  • Kev paub tuaj yeem txhim kho ntxiv los ntawm kev hloov lub suab nrov ntawm Buzzer siv Arduino PWM pins.

Peb yuav pib los ntawm qhov pib thiab yuav tsim lub suab nrov Beeping yooj yim siv Piezo.

Kauj Ruam 1: Sau Cov Khoom

Sau Qhov Chaw
Sau Qhov Chaw

Rau qhov haujlwm no peb yuav xav tau:

  1. Ib Arduino UNO
  2. A 5V Piezo Buzzer
  3. Jumper xov hlau

Tsis yog peb xav tau tus tiv thaiv kom txwv qhov tam sim no los ntawm lub buzzer?

Tsis yog, yog tias koj siv me me 5V Piezo.

Raws li nws tau los lossis siv qhov tsawg heev ntawm qhov tam sim no tuaj yeem siv tau yam tsis muaj tus tiv thaiv hauv koob.

Kauj ruam 2: Kev thaiv kab

Thaiv
Thaiv
Thaiv
Thaiv
Thaiv
Thaiv
Thaiv
Thaiv

Hookup tag nrho cov khoom siv raws li kab lus pom saum toj no.

Polarity ntawm lub buzzer:

Ua ntej txuas Piezo rau Arduino, nco ntsoov tias Piezo buzzer muaj qhov sib txawv.

  1. Qhov ua tau zoo ntawm Piezo muaj Red wire.
  2. Tab sis, Yog tias koj tau txais Breadboard mountable Piezo tom qab ntawd Lub davhlau ya nyob twg zoo ntawm Piezo muaj cov hlau lead ntev dua li cov dav hlau tsis zoo.

Kauj ruam 3: Arduino Sketch

Arduino Sketch
Arduino Sketch

Thaum koj tau txuas txhua yam, Rub cov hauv qab no rau Arduino:

void teeb tsa () {

pinMode (9, NTAWV); // tshaj tawm tus pin 9 los ua qhov tso tawm:

}

void voj () {

analogWrite (9, 20); // Txhua tus nqi tuaj yeem siv tshwj tsis yog 0 thiab 255

ncua (300); // tos rau 3 ms

analogWrite (9, 0); // tig nws tawm

ncua (300); // tos rau 3 ms

}

Kauj ruam 4: Ua tiav

Ua tiav
Ua tiav

Thaum ua tiav lub hwj chim Arduino kom hnov lub suab nrov.

Teeb meem:

Tsis muaj suab

Txheeb xyuas tias lub buzzer txuas nrog rau arduino kom raug

Koj puas tau tso lub buzzer rau tus pin raug?

Ua tib zoo saib ntawm Polarity ntawm Piezo buzzer. Ntawd yog, Tus coj zoo ntawm lub suab nrov yuav tsum mus rau tus lej 9 thiab tsis zoo rau GND ntawm Arduino feem

Yog tias koj tseem tsis tuaj yeem hnov Re-upload daim duab.

Los yog, Sau hauv cov lus hauv qab no.

Tsaug rau saib.

Pom zoo: