Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* 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: IoT Trigger - Source Code NOT compiled for: Arduino Uno - Source Code created on: 2024-08-14 14:01:07 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Implement a button press detection system using */ /* the EasyButton library to trigger actions in the */ /* IoTController, ensuring seamless integration with */ /* connected devices and user-friendly interaction. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
//https://github.com/evert-arias/EasyButton #include
//https://github.com/AndresDuran53/zarus-network-controller /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t button_PushButton_PIN_D2 = 2; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // Create an instance of EasyButton for the push button EasyButton button(button_PushButton_PIN_D2); // Initialize EasyButton with the pin number // Create an instance of IoTController IoTController iotController("button-controller", 1); // Initialize IoTController with a name and number of data points /****** FUNCTION DEFINITIONS *****/ // Callback function to be called when the button is pressed void onButtonPressed() { Serial.println("Button pressed! Triggering IoT action."); // Here you can add code to trigger actions in the IoTController // For example, you can send a message or change a state iotController.addCommonData("button_state", "boolean", 1, "true", "bool", nullptr); // Example of adding data } void setup(void) { // put your setup code here, to run once: pinMode(button_PushButton_PIN_D2, INPUT_PULLUP); // Set the button pin as input with pull-up resistor // Initialize Serial for debugging purposes Serial.begin(115200); Serial.println(); Serial.println(">>> EasyButton example <<<"); // Initialize the button button.begin(); // Call begin() to initialize the button button.onPressed(onButtonPressed); // Attach the callback function for button press // Initialize IoTController iotController.setup(); // Call setup() to initialize the IoTController } void loop(void) { // Continuously read the status of the button button.read(); // Update the button state // Call the loop function of IoTController iotController.loop(); // Ensure IoTController processes its tasks } /* END CODE */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)