/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: Distance - Source Code compiled for: Arduino Uno - Source Code created on: 2023-12-02 18:56:42 - Source Code generated by: Swetha ********* Pleasedontcode.com **********/ /****** DEFINITION OF LIBRARIES *****/ #include /****** SYSTEM REQUIREMENT 1 *****/ const int LED_PIN = 13; // LED pin /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t SENSOR_DHT11_DOUT_PIN = 2; // DHT11 sensor pin /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/ DHT dht(SENSOR_DHT11_DOUT_PIN, DHT11); // DHT sensor instance void setup(void) { pinMode(LED_PIN, OUTPUT); // Set LED pin as output dht.begin(); // Initialize DHT sensor Serial.begin(9600); // Initialize serial communication } void loop(void) { digitalWrite(LED_PIN, HIGH); // Turn on LED // Read humidity and temperature from the DHT sensor float humidity = dht.readHumidity(); float temperature = dht.readTemperature(); // Check if the readings are valid if (isnan(humidity) || isnan(temperature)) { Serial.println(F("Failed to read from DHT sensor!")); } else { Serial.print(F("Humidity: ")); Serial.print(humidity); Serial.print(F("% Temperature: ")); Serial.print(temperature); Serial.println(F("°C")); } digitalWrite(LED_PIN, LOW); // Turn off LED delay(2000); // Wait for 2 seconds before taking another reading }