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: "LED Activation" - Source Code NOT compiled for: Arduino Nano - Source Code created on: 2024-05-23 14:53:10 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* If the button is pressed 3 times, let the LED */ /* light up */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
//https://github.com/evert-arias/EasyButton /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void onSequenceMatched(void); // Function prototype for sequence matched callback /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t Button_PushButton_PIN_D2 = 2; const uint8_t LED_PIN = 13; // Define the LED pin /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton button(Button_PushButton_PIN_D2); // Initialize EasyButton object with the pin number void onSequenceMatched() { Serial.println("Button pressed 3 times"); // Callback function to be called when the button sequence is matched digitalWrite(LED_PIN, HIGH); // Turn on the LED } void setup(void) { // put your setup code here, to run once: Serial.begin(115200); // Initialize serial communication at 115200 baud rate Serial.println(); Serial.println(">>> EasyButton sequence example <<<"); button.begin(); // Initialize the button button.onSequence(3, 2000, onSequenceMatched); // Set up the sequence detection: 3 presses within 2000ms pinMode(Button_PushButton_PIN_D2, INPUT_PULLUP); // Set the button pin as input with pull-up resistor pinMode(LED_PIN, OUTPUT); // Set the LED pin as output digitalWrite(LED_PIN, LOW); // Ensure the LED is off initially } void loop(void) { // put your main code here, to run repeatedly: button.read(); // Read the button state } /* 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)