Pezonurlatgich.(Buzzer musiqa notasi). Pezonurlatgich(Buzzer) datchigini boshqarish: tonni o‘zgartirish. Transtistor xususiyatini namoyish etish. Elektrorichak misolida aylanish o‘zgartirish. Rele
Download 1.09 Mb.
|
OT 5-6 lab Oyazimxon
56-rasm. DHT 22 Ulanish sxemasi.
#include "DHT.h" #define DHTPIN 2 #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(115200); Serial.println(F("DHT22 example!")); dht.begin(); } void loop() { float temperature = dht.readTemperature(); float humidity = dht.readHumidity(); // Check if any reads failed and exit early (to try again). if (isnan(temperature) || isnan(humidity)) { Serial.println(F("Failed to read from DHT sensor!")); return; } Serial.print(F("Humidity: ")); Serial.print(humidity); Serial.print(F("% Temperature: ")); Serial.print(temperature); Serial.println(F("°C ")); // Wait a few seconds between measurements. delay(2000); } DHT22 (AM2302) termo-va-issyqlik datchisi juda yuqori qulaylik va to‘g‘ri ishlashga ega bo‘lsa ham, uning bir nechta kamchiliklari mavjud bo‘lishi mumkin. Quyidagi kamchiliklarni eslatibo‘tamiz: Javob uzatish va narxi: DHT22-nio‘qish uchun kamchiliklardan biri,o‘qish uchun javob uzatishi vaqtinchalik bo‘lishi mumkin. Buning natijasida Arduino va boshqa mikrokontrollerlar bir oz davom etishi mumkin. Datchio‘qish jarayonida keyinchalik kamchiliklar nazariga olinishi mumkin, bu esa natijalarning kech bo‘lishiga olib kelishi mumkin. 5-labaratoriya #define BUZZER_PIN 9 void setup() { pinMode(BUZZER_PIN, OUTPUT); } void loop() { playDespacito(); } void playTone(int note, int duration) { tone(BUZZER_PIN, note, duration); delay(duration); noTone(BUZZER_PIN); delay(50); // Kichik buzzer vaqtinio‘tkazish uchun kuting } void playDespacito() { int tempo = 125; // Musiqa tezligi (bpm) playTone(659, tempo); // E5 nota playTone(659, tempo); playTone(698, tempo); // F5 nota playTone(784, tempo); // G5 nota playTone(698, tempo); // F5 nota playTone(659, tempo); // E5 nota playTone(587, tempo); // D5 nota delay(tempo);} 6-labaratoriya int baselineTemp = 0; int celsius = 0; int fahrenheit = 0; void setup() { pinMode(A0, INPUT); Serial.begin(9600); pinMode(13, OUTPUT); pinMode(8, OUTPUT); pinMode(7, OUTPUT); } void loop() { baselineTemp = 40; celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125); fahrenheit = ((celsius * 9) / 5 + 32); Serial.print(celsius); Serial.print(" C, "); Serial.print(fahrenheit); Serial.println(" F"); if (celsius < baselineTemp) { digitalWrite(13, LOW); digitalWrite(8, LOW); digitalWrite(7, LOW); } if (celsius >= baselineTemp && celsius < baselineTemp + 10) { digitalWrite(13, HIGH); digitalWrite(8, LOW); digitalWrite(7, LOW); } if (celsius >= baselineTemp + 10 && celsius < baselineTemp + 20) { digitalWrite(13, HIGH); digitalWrite(8, HIGH); digitalWrite(7, LOW); } if (celsius >= baselineTemp + 20 && celsius < baselineTemp + 30) { digitalWrite(13, HIGH); digitalWrite(8, HIGH); digitalWrite(7, HIGH); } if (celsius >= baselineTemp + 30) { digitalWrite(13, HIGH); digitalWrite(8, HIGH); digitalWrite(7, HIGH); } delay(1000); } Download 1.09 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling