Dasturni fumksional tugmalari



Yüklə 13,28 Kb.
tarix14.06.2023
ölçüsü13,28 Kb.
#129791
kod


Dasturni fumksional tugmalari
#include // Include the DHT sensor library
#define DHTPIN 2 // Define the digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // Define the type of DHT sensor you are using
DHT dht(DHTPIN, DHTTYPE); // Create a DHT object
void setup() {
Serial.begin(9600); // Initialize serial communication for displaying the readings
dht.begin(); // Initialize the DHT sensor
}
void loop() {
delay(2000); // Delay for 2 seconds
float humidity = dht.readHumidity(); // Read humidity value from the sensor
float temperature = dht.readTemperature(); // Read temperature value from the sensor in Celsius
// Check if any reading failed
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Print the humidity and temperature values
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("%\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println("°C");
}
Yüklə 13,28 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin