Advertisement
pleasedontcode

**Flame Alarm** rev_04

Feb 3rd, 2025
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: **Flame Alarm**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-02-03 21:52:30
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Develop a flame sensor system using Arduino that */
  21.     /* triggers a passive buzzer alarm when flame is */
  22.     /* detected. Utilize ezBuzzer and forcedBMX280 */
  23.     /* libraries for buzzer control and environmental */
  24.     /* data monitoring. Ensure accurate and timely */
  25.     /* alerts. */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28. /* START CODE */
  29.  
  30. /****** DEFINITION OF LIBRARIES *****/
  31. #include <ezBuzzer.h>    // Buzzer control library
  32. #include <forcedBMX280.h> // Environmental data monitoring library
  33.  
  34. /****** FUNCTION PROTOTYPES *****/
  35. void setup(void);
  36. void loop(void);
  37. void updateOutputs();
  38. void checkFlameSensor();
  39.  
  40. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  41. const uint8_t pb_PassiveBuzzer_Signal_PIN_D2 = 2;
  42.  
  43. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  44. bool pb_PassiveBuzzer_Signal_PIN_D2_rawData = 0;
  45.  
  46. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  47. float pb_PassiveBuzzer_Signal_PIN_D2_phyData = 0.0;
  48.  
  49. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  50. // Create instances of the buzzer and sensor
  51. ezBuzzer buzzer(pb_PassiveBuzzer_Signal_PIN_D2);
  52. ForcedBMX280 sensor; // Assuming default I2C address and bus
  53.  
  54. void setup(void)
  55. {
  56.     // put your setup code here, to run once:
  57.     pinMode(pb_PassiveBuzzer_Signal_PIN_D2, OUTPUT);
  58.     buzzer.stop(); // Ensure the buzzer is off at startup
  59.  
  60.     // Initialize the sensor
  61.     if (sensor.begin() != ERROR_OK) {
  62.         // Handle sensor initialization error
  63.         while (1);
  64.     }
  65. }
  66.  
  67. void loop(void)
  68. {
  69.     // put your main code here, to run repeatedly:
  70.     checkFlameSensor(); // Check the flame sensor
  71.     updateOutputs(); // Refresh output data
  72. }
  73.  
  74. void checkFlameSensor()
  75. {
  76.     // Simulated flame detection logic
  77.     // Replace this with actual flame sensor reading logic
  78.     int flameDetected = analogRead(A0); // Assuming the flame sensor is connected to A0
  79.  
  80.     if (flameDetected > 500) { // Threshold for flame detection
  81.         pb_PassiveBuzzer_Signal_PIN_D2_rawData = HIGH; // Trigger buzzer
  82.         buzzer.beep(1000); // Beep for 1 second
  83.     } else {
  84.         pb_PassiveBuzzer_Signal_PIN_D2_rawData = LOW; // Stop buzzer
  85.     }
  86. }
  87.  
  88. void updateOutputs()
  89. {
  90.     digitalWrite(pb_PassiveBuzzer_Signal_PIN_D2, pb_PassiveBuzzer_Signal_PIN_D2_rawData);
  91. }
  92.  
  93. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement