Cov txheej txheem:

Lub teeb Sensor Buzzer: 5 Kauj Ruam
Lub teeb Sensor Buzzer: 5 Kauj Ruam

Video: Lub teeb Sensor Buzzer: 5 Kauj Ruam

Video: Lub teeb Sensor Buzzer: 5 Kauj Ruam
Video: 99.5% Players Failed This Part Because They Were Distracted 2024, Hlis ntuj nqeg
Anonim
Lub teeb Sensor Buzzer
Lub teeb Sensor Buzzer

Hauv qhov kev sim no peb yuav ua haujlwm nrog lub sensor uas yog tus tiv thaiv uas nyob ntawm lub teeb. Hauv qhov chaw tsaus, tus tiv thaiv yuav muaj qhov ua haujlwm siab heev. Raws li photons lub teeb tsaws ntawm tus ntes, qhov ua haujlwm yuav txo qis. Qhov pom kev ntau dua yog peb yuav muaj kev tiv thaiv qis dua. Los ntawm kev nyeem qhov sib txawv ntawm qhov ntsuas, peb tuaj yeem kuaj pom yog nws lub teeb, tsaus ntuj lossis tus nqi nruab nrab ntawm lawv. Lwm qhov uas peb yuav siv rau ntawm qhov kev sim no yog Buzzer.

Kauj Ruam 1: Teeb tsa Circuit thiab Beadboard

Teeb Circuit Court thiab Beadboard
Teeb Circuit Court thiab Beadboard

Cov txheej txheem muaj 3 yam uas yog: Photoresistor (LDR), Piezo Buzzer, 1 - 10 kΩ. LDR tuaj yeem txuas nrog txhua txoj hauv kev uas koj xav tau vim nws tsis muaj qhov sib txawv. Txog kev tiv thaiv koj tuaj yeem siv los ntawm 1-10 KΩ vim tias LDR sib txawv muaj qhov sib txawv. Sim sib txawv qhov tseem ceeb ntawm tus tiv thaiv kom haum rau qhov zoo tshaj plaws nrog koj LDR.

Kauj ruam 2: Code

Code
Code

int piezoPin = 8; // Tshaj tawm Piezo Buzzer ntawm tus Pin 8

int ldrPin = 0; // Tshaj tawm LDR ntawm Analog Pin 0

int ldrValue = 0; // Nyeem qhov sib txawv ntawm LDR

teeb tsa teeb tsa

()

{ }

void lub voj ()

{// Pib lub voj voog ua haujlwm hauv qab no

ldrValue = analogRead (ldrPin); // nyeem tus nqi los ntawm LDR

suab (piezoPin, 1000); // Ua si 1000Hz suab los ntawm piezo (beep)

ncua (25); // tos me ntsis, hloov qhov ncua rau kev teb sai.

noTone (piezoPin); // nres lub suab tom qab 25 ms hauv qhov no

ncua (ldrValue); // tos tus nqi milliseconds hauv ldrValue} //

Xaus kev ua haujlwm

Kauj Ruam 3: Cov ntaub ntawv

Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv

1. Cov qhob cij

2. Pawg Tswj Xyuas Arduino

3. Txiv neej Hlau

4. Cov neeg tiv taus

5. Piezo Buzzer

6. Lub teeb Sensor

Pom zoo: