Cov txheej txheem:

Yuav Ua Li Cas Cov Ntsuas Kub Kub #1: 4 Cov Kauj Ruam
Yuav Ua Li Cas Cov Ntsuas Kub Kub #1: 4 Cov Kauj Ruam

Video: Yuav Ua Li Cas Cov Ntsuas Kub Kub #1: 4 Cov Kauj Ruam

Video: Yuav Ua Li Cas Cov Ntsuas Kub Kub #1: 4 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Yuav Ua Li Cas Thiaj Li Tus Ntsuas Kub #1
Yuav Ua Li Cas Thiaj Li Tus Ntsuas Kub #1

Hauv kab lus no kuv yuav ua qhov haujlwm hu ua "Digital Thermometer". Kuv siv "DHT11" rau qhov ntsuas kub. Thiab siv "7Segmrnt Module" ua cov zaub.

Kuv pom zoo nyeem kab ntawv no ua ntej "DHT11" thiab "7-Segment Module". Hauv kab lus ntawd kuv tau piav qhia yuav siv DHT11 thiab 7Segment Module li cas

Kauj ruam 1: Yuav tsum muaj Componens

Yuav tsum tau Componens
Yuav tsum tau Componens
Yuav tsum tau Componens
Yuav tsum tau Componens
Yuav tsum tau Componens
Yuav tsum tau Componens

Nov yog cov khoom uas peb xav tau hauv txoj haujlwm no:

  • DHT11 Senosor
  • MAX7219 7 ntu
  • Arduino Nano V3
  • Jumper Hlau
  • USBmini
  • Pawg Thawj Coj

Yuav tsum muaj tsev qiv ntawv:

  • DHT
  • LedControl

Kauj Ruam 2: Sib Sau Ua Ke Txhua Yam

Sib Sau Ua Ke Txhua Yam
Sib Sau Ua Ke Txhua Yam

Saib daim duab saum toj no rau kev taw qhia txog kev sib sau ua ke. Los yog saib cov ntaub ntawv hauv qab no:

Arduino rau 7Segment Module

+5V => VCC

GND => GND

D12 => DIN

D11 => CLK

D10 => CSJ

Arduino rau DHT11

+5V => +

NPV => -

D2 => tawm

Tom qab txhua qhov txuas tau txuas nrog, cia peb mus rau ntu ntu ntawm lub cajmeem

Kauj ruam 3: Programming

Programming
Programming

Hauv qab no yog cov duab kos uas kuv tau siv hauv txoj haujlwm no lossis qhia. Koj tuaj yeem siv daim duab kos no rau koj qhov project.

#suav nrog "DHT.h"#suav nrog "LedControl.h"

#define DHTPIN 2

#define DHTTYPE DHT11

LedControl lc = LedControl (12, 11, 10, 1);

DHT dht (DHTPIN, DHTTYPE);

teeb tsa tsis muaj dab tsi () {Serial.begin (9600); Serial.println (F ("Digital Thermoeter")); dht.begin (); lc.shutdown (0, tsis tseeb); lc.setIntensity (0, 8); lc.clearDisplay (0); }

void voj () {

ncua (2000); ntab h = dht.readHumidity (); ntab t = dht.readTemperature (); ntab f = dht.readTemperature (muaj tseeb); yog (isnan (h) || isnan (t) || isnan (f)) {Serial.println (F ("Ua tsis tau tejyam nyeem los ntawm DHT sensor!")); rov qab; } ntab hif = dht.computeHeatIndex (f, h);

ntab hic = dht.computeHeatIndex (t, h, cuav);

Serial.print (F ("Kub:"));

Serial.print (t); Serial.println (F ("° C"));

ncua (1000);

char kuv = t; lc.setDigit (0, 3, t/10, tsis tseeb); lc.setDigit (0, 2, i%10, tsis tseeb); lc.setChar (0, 0, 0b1100, tsis tseeb); ncua (400);

}

tom qab kos duab tiav, nyem upload thiab tos kom nws ua tiav.

Kuv kuj muab cov duab kos hauv daim ntawv ".ino" cov ntaub ntawv. Cov ntawv tuaj yeem rub tawm hauv qab no.

Kauj Ruam 4: Qhov tshwm sim

Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim

Saib daim duab saum toj no kom pom cov txiaj ntsig.

rau txoj haujlwm no kuv tsuas yog ntsuas kub Celsius nkaus xwb. Txog qib Fahrenheit qhov kub thiab txias, kuv yuav ua kab lus tom ntej.

Ua tsaug rau koj nyeem kab lus no, yog tias koj muaj lus nug, thov sau hauv kab lus.

Pom koj hauv kab lus tom ntej.

Pom zoo: