Advertisement
pleasedontcode

Digital Control rev_03

Feb 24th, 2024
80
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: Digital Control
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-02-24 07:17:53
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* turn on  activebuzzer when humiditi hit below 70% */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* stop activebuzzer when humidity is above 90% */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include "DHT.h"
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31. void updateOutputs(void);
  32.  
  33. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  34. const uint8_t humiditysensor_DHT22_DOUT_PIN_D2 = 2;
  35. const uint8_t humiditysensor_DHT22_DOUT_PIN_D3 = 3;
  36.  
  37. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  38. const uint8_t ultrasonichumid_ActiveBuzzer_output_PIN_D4 = 4;
  39. const uint8_t ultrasonichumid_ActiveBuzzer_output_PIN_D5 = 5;
  40.  
  41. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  42. /***** used to store raw data *****/
  43. bool ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData = 0;
  44. bool ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData = 0;
  45.  
  46. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  47. /***** used to store data after characteristic curve transformation *****/
  48. float ultrasonichumid_ActiveBuzzer_output_PIN_D4_phyData = 0.0;
  49. float ultrasonichumid_ActiveBuzzer_output_PIN_D5_phyData = 0.0;
  50.  
  51. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  52. DHT dht(humiditysensor_DHT22_DOUT_PIN_D2, DHT22);
  53.  
  54. void setup(void)
  55. {
  56.   // put your setup code here, to run once:
  57.  
  58.   pinMode(humiditysensor_DHT22_DOUT_PIN_D2, INPUT_PULLUP);
  59.   pinMode(humiditysensor_DHT22_DOUT_PIN_D3, INPUT_PULLUP);
  60.  
  61.   pinMode(ultrasonichumid_ActiveBuzzer_output_PIN_D4, OUTPUT);
  62.   pinMode(ultrasonichumid_ActiveBuzzer_output_PIN_D5, OUTPUT);
  63.  
  64.   dht.begin();
  65. }
  66.  
  67. void loop(void)
  68. {
  69.   // put your main code here, to run repeatedly:
  70.  
  71.   float humidity = dht.readHumidity();
  72.  
  73.   if (humidity < 70) {
  74.     ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData = 1; // turn on active buzzer
  75.     ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData = 0;
  76.   } else if (humidity > 90) {
  77.     ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData = 0; // stop active buzzer
  78.     ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData = 0;
  79.   } else {
  80.     ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData = 0;
  81.     ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData = 1;
  82.   }
  83.  
  84.   updateOutputs(); // Refresh output data
  85. }
  86.  
  87. void updateOutputs(void)
  88. {
  89.   digitalWrite(ultrasonichumid_ActiveBuzzer_output_PIN_D4, ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData);
  90.   digitalWrite(ultrasonichumid_ActiveBuzzer_output_PIN_D5, ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData);
  91. }
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement