Advertisement
pleasedontcode

Temperature Tracker rev_01

Apr 19th, 2024
41
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: Temperature Tracker
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-04-19 16:18:50
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The system shall read temperature data from a */
  21.     /* DS18B20 sensor connected to pin D2. */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <OneWire.h>
  26. #include <DallasTemperature.h>
  27.  
  28. /****** SYSTEM REQUIREMENTS *****/
  29. /****** SYSTEM REQUIREMENT 1 *****/
  30. /* The system shall read temperature data from a */
  31. /* DS18B20 sensor connected to pin D2. */
  32. /****** END SYSTEM REQUIREMENTS *****/
  33.  
  34. /****** FUNCTION PROTOTYPES *****/
  35. void setup(void);
  36. void loop(void);
  37.  
  38. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  39. const uint8_t Temp_sensor_DS18B20_DQ_PIN_D2 = 2;
  40.  
  41. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  42. OneWire oneWire(Temp_sensor_DS18B20_DQ_PIN_D2);
  43. DallasTemperature sensors(&oneWire);
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.   sensors.begin();
  49.   Serial.begin(9600);
  50. }
  51.  
  52. void loop(void)
  53. {
  54.   // put your main code here, to run repeatedly:
  55.   sensors.requestTemperatures();
  56.   float temperature = sensors.getTempCByIndex(0);
  57.   Serial.print("Temperature: ");
  58.   Serial.println(temperature);
  59.   delay(1000);
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement