Advertisement
pleasedontcode

Temperature Control rev_01

Apr 23rd, 2024
61
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 Control
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-04-23 12:36:37
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* #include <math.h>  const int TEMP_SENSOR_PIN = 2; */
  21.     /* const int MOSFET_PIN = 6;  const int */
  22.     /* TEMP_THRESHOLD_1 = 70;  const int TEMP_THRESHOLD_2 */
  23.     /* = 80;  const int TEMP_THRESHOLD_3 = 90;  const int */
  24.     /* TEMP_THRESHOLD_4 = 100;  const int PWM_FREQUENCY = */
  25.     /* 25; */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <DS18B20.h>    //https://github.com/matmunk/DS18B20
  30.  
  31. /****** SYSTEM REQUIREMENTS *****/
  32. #include <math.h>
  33. const int TEMP_SENSOR_PIN = 2;
  34. const int MOSFET_PIN = 6;
  35. const int TEMP_THRESHOLD_1 = 70;
  36. const int TEMP_THRESHOLD_2 = 80;
  37. const int TEMP_THRESHOLD_3 = 90;
  38. const int TEMP_THRESHOLD_4 = 100;
  39. const int PWM_FREQUENCY = 25;
  40. /****** END SYSTEM REQUIREMENTS *****/
  41.  
  42. /****** FUNCTION PROTOTYPES *****/
  43. void setup(void);
  44. void loop(void);
  45.  
  46. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  47. const uint8_t gm_DS18B20_DQ_PIN_D2 = 2;
  48.  
  49. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  50. DS18B20 ds(2); // Initialize an object of the DS18B20 class with pin 2
  51.  
  52. void setup(void)
  53. {
  54.     // put your setup code here, to run once:
  55.     ds.resetSearch();
  56.     while (ds.selectNext()) {
  57.         ds.setAlarms(TEMP_THRESHOLD_1, TEMP_THRESHOLD_2);
  58.     }
  59.  
  60. }
  61.  
  62. void loop(void)
  63. {
  64.     // put your main code here, to run repeatedly:
  65.     ds.doConversion();
  66.  
  67.     ds.resetSearch();
  68.     while (ds.selectNextAlarm()) {
  69.         Serial.print("Alarm Low: ");
  70.         Serial.print(ds.getAlarmLow());
  71.         Serial.println(" C");
  72.         Serial.print("Alarm High: ");
  73.         Serial.print(ds.getAlarmHigh());
  74.         Serial.println(" C");
  75.         Serial.print("Temperature: ");
  76.         Serial.print(ds.getTempC());
  77.         Serial.println(" C\n");
  78.     }
  79.  
  80.     delay(10000);
  81. }
  82.  
  83. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement