Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Flame Buzzer
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-05-18 20:21:48
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Turns on and off when it senses flame */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <ezBuzzer.h> //https://github.com/ArduinoGetStarted/buzzer
- #include <DHT.h> //https://github.com/adafruit/DHT-sensor-library
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void); // Added function prototype
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t FlameSensor_DHT22_DOUT_PIN_D3 = 3;
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t PassiveBuzzer_Signal_PIN_D2 = 2; // Corrected variable name
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- bool PassiveBuzzer_Signal_PIN_D2_rawData = 0; // Corrected variable name
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- float PassiveBuzzer_Signal_PIN_D2_phyData = 0.0; // Corrected variable name
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- const int BUZZER_PIN = 5; // Define the buzzer pin
- ezBuzzer buzzer(BUZZER_PIN); // Initialize the ezBuzzer object with the buzzer pin
- #define DHTPIN 3
- #define DHTTYPE DHT22
- DHT dht(DHTPIN, DHTTYPE); // Initialize the DHT sensor object with the pin and type
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(FlameSensor_DHT22_DOUT_PIN_D3, INPUT_PULLUP);
- pinMode(PassiveBuzzer_Signal_PIN_D2, OUTPUT);
- dht.begin(); // Initialize the DHT sensor
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- if (digitalRead(FlameSensor_DHT22_DOUT_PIN_D3) == HIGH) {
- PassiveBuzzer_Signal_PIN_D2_rawData = 1; // Turn on the buzzer
- } else {
- PassiveBuzzer_Signal_PIN_D2_rawData = 0; // Turn off the buzzer
- }
- }
- void updateOutputs(void)
- {
- digitalWrite(PassiveBuzzer_Signal_PIN_D2, PassiveBuzzer_Signal_PIN_D2_rawData);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement