Advertisement
pleasedontcode

Flame Control rev_01

May 18th, 2024
841
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: Flame Control
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-18 20:19:33
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Turns on and off when it senses flame */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <ezBuzzer.h>   //https://github.com/ArduinoGetStarted/buzzer
  25. #include <DHT.h>    //https://github.com/adafruit/DHT-sensor-library
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30. void updateOutputs(void); // Added function prototype
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t FlameSensor_DHT22_DOUT_PIN_D3 = 3;
  34.  
  35. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  36. const uint8_t PassiveBuzzer_Signal_PIN_D2 = 2; // Corrected variable name
  37.  
  38. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  39. bool PassiveBuzzer_Signal_PIN_D2_rawData = 0; // Corrected variable name
  40.  
  41. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  42. float PassiveBuzzer_Signal_PIN_D2_phyData = 0.0; // Corrected variable name
  43.  
  44. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  45. const int BUZZER_PIN = 5; // Define the buzzer pin
  46.  
  47. ezBuzzer buzzer(BUZZER_PIN); // Initialize the ezBuzzer object with the buzzer pin
  48.  
  49. #define DHTPIN 3
  50. #define DHTTYPE DHT22
  51.  
  52. DHT dht(DHTPIN, DHTTYPE); // Initialize the DHT sensor object with the pin and type
  53.  
  54. void setup(void)
  55. {
  56.     // put your setup code here, to run once:
  57.     pinMode(FlameSensor_DHT22_DOUT_PIN_D3, INPUT_PULLUP);
  58.     pinMode(PassiveBuzzer_Signal_PIN_D2, OUTPUT);
  59.     dht.begin(); // Initialize the DHT sensor
  60. }
  61.  
  62. void loop(void)
  63. {
  64.     // put your main code here, to run repeatedly:
  65.     updateOutputs(); // Refresh output data
  66.  
  67.     if (digitalRead(FlameSensor_DHT22_DOUT_PIN_D3) == HIGH) {
  68.         PassiveBuzzer_Signal_PIN_D2_rawData = 1; // Turn on the buzzer
  69.     } else {
  70.         PassiveBuzzer_Signal_PIN_D2_rawData = 0; // Turn off the buzzer
  71.     }
  72. }
  73.  
  74. void updateOutputs(void)
  75. {
  76.     digitalWrite(PassiveBuzzer_Signal_PIN_D2, PassiveBuzzer_Signal_PIN_D2_rawData);
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement