Advertisement
pleasedontcode

Sensor Readings rev_01

Jan 6th, 2024
131
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: Sensor Readings
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-06 18:18:03
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* bhhhhhhhvgbh yubjyhu */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Arduino.h>
  25. #include <DHT.h>
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  32. const uint8_t DHTPIN = 2;
  33.  
  34. /****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
  35. DHT dht(DHTPIN, DHT22);
  36.  
  37. void setup(void)
  38. {
  39.     // put your setup code here, to run once:
  40.     pinMode(DHTPIN, INPUT_PULLUP);
  41.     dht.begin();
  42.    
  43.     // System Requirement 1: Initialize Serial communication
  44.     Serial.begin(9600);
  45. }
  46.  
  47. void loop(void)
  48. {
  49.     // put your main code here, to run repeatedly:
  50.     delay(2000); // System Requirement 2: Delay before each measurement
  51.    
  52.     // Read temperature and humidity from DHT sensor
  53.     float temperature = dht.readTemperature();
  54.     float humidity = dht.readHumidity();
  55.    
  56.     // System Requirement 3: Print temperature and humidity values
  57.     Serial.print("Temperature: ");
  58.     Serial.print(temperature);
  59.     Serial.println("°C");
  60.    
  61.     Serial.print("Humidity: ");
  62.     Serial.print(humidity);
  63.     Serial.println("%");
  64. }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement