Advertisement
pleasedontcode

Dust rev_01

Dec 5th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Dust
  13.     - Source Code compiled for: Arduino Mega
  14.     - Source Code created on: 2023-12-05 14:42:53
  15.     - Source Code generated by: Johnny van Aardt
  16.  
  17. ********* Pleasedontcode.com **********/
  18.  
  19. /****** SYSTEM REQUIREMENTS *****/
  20. /****** SYSTEM REQUIREMENT 1 *****/
  21.     /* Display temperature and humidity values */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h>
  26. #include <DHT.h>
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /****** SYSTEM REQUIREMENTS *****/
  33. /****** SYSTEM REQUIREMENT 1 *****/
  34. /* Display temperature and humidity values */
  35. /****** END SYSTEM REQUIREMENTS *****/
  36.  
  37. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  38. const uint8_t Enviro_DHT22_DOUT_PIN_D2 = 2;
  39.  
  40. /****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
  41. DHT dht(Enviro_DHT22_DOUT_PIN_D2, DHT22);
  42.  
  43. void setup(void)
  44. {
  45.   // put your setup code here, to run once:
  46.   pinMode(Enviro_DHT22_DOUT_PIN_D2, INPUT_PULLUP);
  47.   Serial.begin(9600);
  48.   dht.begin();
  49. }
  50.  
  51. void loop(void)
  52. {
  53.   // put your main code here, to run repeatedly:
  54.   delay(2000);
  55.  
  56.   float h = dht.readHumidity();
  57.   float t = dht.readTemperature();
  58.   float f = dht.readTemperature(true);
  59.  
  60.   if (isnan(h) || isnan(t) || isnan(f))
  61.   {
  62.     Serial.println(F("Failed to read from DHT sensor!"));
  63.     return;
  64.   }
  65.  
  66.   Serial.print(F("Humidity: "));
  67.   Serial.print(h);
  68.   Serial.print(F("%  Temperature: "));
  69.   Serial.print(t);
  70.   Serial.print(F("°C "));
  71.   Serial.print(f);
  72.   Serial.print(F("°F"));
  73.   Serial.println();
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement