Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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 Data
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-12-18 19:00:35
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* DHT sensor detects an temeperature and if its over */
- /* 25 celsius it beeeeps */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <DHT.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t Temp_DHT11_DOUT_PIN_D3 = 3;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- DHT dht(Temp_DHT11_DOUT_PIN_D3, DHT11);
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(9600);
- dht.begin();
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- float humidity = dht.readHumidity();
- float temperature = dht.readTemperature();
- // Check if any reads failed and exit early (to try again).
- if (isnan(humidity) || isnan(temperature)) {
- Serial.println("Failed to read from DHT sensor!");
- return;
- }
- Serial.print("Humidity: ");
- Serial.print(humidity);
- Serial.print(" %\t");
- Serial.print("Temperature: ");
- Serial.print(temperature);
- Serial.print(" °C\t");
- Serial.print("Temperature: ");
- Serial.print(dht.readTemperature(true));
- Serial.println(" °F");
- // Check if temperature is over 25°C and beep
- if (temperature > 25) {
- // Beep code here
- Serial.println("Temperature is over 25°C. Beeping...");
- }
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement