/********* 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: "Smart Monitoring" - Source Code compiled for: Arduino Uno - Source Code created on: 2024-01-01 12:28:36 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Measures temperature If temperature is greater */ /* than 27 degrees celsius print "high temp" and turn */ /* on red LED if temperature is less than 25 */ /* degrees celsius print "low temp" and turn on blue */ /* LED create this in a function called water_temp */ /****** SYSTEM REQUIREMENT 2 *****/ /* Measure distance If distance is greater than */ /* 30 cm print "water overflow " and turn buzzer on */ /* If distance is less than 15 cm print "water */ /* underflow " and turn buzzer on create this in */ /* a function called water_level */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include #include #include /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void water_temp(void); void water_level(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t mydht_DHT11_DOUT_PIN_D2 = 2; const uint8_t myUS_HC_SR04_Echo_PIN_D4 = 4; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t myUS_HC_SR04_Trigger_PIN_D3 = 3; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ DHT dht(mydht_DHT11_DOUT_PIN_D2, DHT11); Ultrasonic ultrasonic(myUS_HC_SR04_Trigger_PIN_D3, myUS_HC_SR04_Echo_PIN_D4); void setup(void) { // put your setup code here, to run once: pinMode(mydht_DHT11_DOUT_PIN_D2, INPUT_PULLUP); pinMode(myUS_HC_SR04_Echo_PIN_D4, INPUT); pinMode(myUS_HC_SR04_Trigger_PIN_D3, OUTPUT); } void loop(void) { // put your main code here, to run repeatedly: water_temp(); water_level(); } void water_temp(void) { float temp = dht.readTemperature(); if (temp > 27) { Serial.println("High temperature"); // Turn on red LED } else if (temp < 25) { Serial.println("Low temperature"); // Turn on blue LED } } void water_level(void) { unsigned int distance = ultrasonic.read(); if (distance > 30) { Serial.println("Water overflow"); // Turn on buzzer } else if (distance < 15) { Serial.println("Water underflow"); // Turn on buzzer } }