Advertisement
pleasedontcode

Button Sensor rev_01

Sep 25th, 2024
58
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: Button Sensor
  13.     - Source Code NOT compiled for: Arduino Pro Mini 3.3V
  14.     - Source Code created on: 2024-09-26 04:46:18
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Aimbot in gpc Cronus zen */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
  25. #include <AS3935-Lightning-sensor-SOLDERED.h>   //https://github.com/SolderedElectronics/Soldered-AS3935-Lightning-detect-Arduino-Library
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  32. const uint8_t Ff_PushButton_PIN_D2      = 2;
  33.  
  34. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  35. // Initialize the EasyButton object with the pin number and default parameters
  36. EasyButton button(Ff_PushButton_PIN_D2);
  37.  
  38. // Initialize the AS3935 lightning sensor object with the default I2C address
  39. AS3935 lightningSensor(0x03); // Using the constructor with the address
  40.  
  41. /****** FUNCTION DEFINITIONS *****/
  42. void setup(void)
  43. {
  44.     // Start serial communication for debugging
  45.     Serial.begin(115200);
  46.    
  47.     // Set the button pin as input with internal pull-up resistor
  48.     pinMode(Ff_PushButton_PIN_D2, INPUT_PULLUP);
  49.  
  50.     // Initialize the EasyButton
  51.     button.begin();
  52.     // Set up a callback function for button press events
  53.     button.onPressed([]() {
  54.         Serial.println("Button has been pressed");
  55.     });
  56.  
  57.     // Initialize the lightning sensor
  58.     if (!lightningSensor.begin()) { // Check if the sensor initializes correctly
  59.         Serial.println("Lightning Detector did not start up, freezing!");
  60.         while (1); // Loop forever if initialization fails
  61.     } else {
  62.         Serial.println("Lightning Detector initialized successfully!");
  63.     }
  64. }
  65.  
  66. void loop(void)
  67. {
  68.     // Read the button state
  69.     button.read();
  70.  
  71.     // Add additional code to handle lightning detection if needed
  72.     // Example: if (lightningSensor.detectLightning()) { ... }
  73. }
  74.  
  75. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement