Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* 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: Sensor Monitoring - Source Code compiled for: Arduino Uno - Source Code created on: 2024-01-01 13:09:29 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Ultrasonic sensor Measures 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. */ /****** SYSTEM REQUIREMENT 2 *****/ /* DHT11 sensors measures temperature If temp is */ /* greater than 27 degrees celsius print "high temp" */ /* and turn red led on. If temp is less than 25 */ /* degrees celcius print "low temp" and turn blue led */ /* on. Create this in a function called "water_temp" */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
#include
#include
/****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void water_level(void); void water_temp(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t myUS_HC_SR04_Echo_PIN_D5 = 5; const uint8_t myDHT_DHT22_DOUT_PIN_D8 = 8; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t myUS_HC_SR04_Trigger_PIN_D4 = 4; const uint8_t buzzer_PIN = 9; const uint8_t red_LED_PIN = 10; const uint8_t blue_LED_PIN = 11; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ Ultrasonic ultrasonic(myUS_HC_SR04_Trigger_PIN_D4, myUS_HC_SR04_Echo_PIN_D5); DHT dht(myDHT_DHT22_DOUT_PIN_D8, DHT22); void setup(void) { // put your setup code here, to run once: pinMode(myUS_HC_SR04_Echo_PIN_D5, INPUT); pinMode(myUS_HC_SR04_Trigger_PIN_D4, OUTPUT); pinMode(buzzer_PIN, OUTPUT); pinMode(red_LED_PIN, OUTPUT); pinMode(blue_LED_PIN, OUTPUT); dht.begin(); Serial.begin(9600); } void loop(void) { // put your main code here, to run repeatedly: water_level(); water_temp(); delay(1000); } void water_level(void) { unsigned int distance = ultrasonic.read(); if (distance > 30) { Serial.println("Water Overflow"); digitalWrite(buzzer_PIN, HIGH); } else if (distance < 15) { Serial.println("Water Underflow"); digitalWrite(buzzer_PIN, HIGH); } else { digitalWrite(buzzer_PIN, LOW); } } void water_temp(void) { float temperature = dht.readTemperature(); if (temperature > 27) { Serial.println("High Temperature"); digitalWrite(red_LED_PIN, HIGH); digitalWrite(blue_LED_PIN, LOW); } else if (temperature < 25) { Serial.println("Low Temperature"); digitalWrite(red_LED_PIN, LOW); digitalWrite(blue_LED_PIN, HIGH); } else { digitalWrite(red_LED_PIN, LOW); digitalWrite(blue_LED_PIN, LOW); } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)