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 Toggle" - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-05-29 11:23:17 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* blinking led when preesed button and stops */ /* blinking when pressed button */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
// https://github.com/evert-arias/EasyButton /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void onButtonPressed(); void updateOutputs(); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t Button1_PushButton_PIN_D4 = 4; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t visualFeedbackLED_LED_PIN_D13 = 13; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool visualFeedbackLED_LED_PIN_D13_rawData = false; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float visualFeedbackLED_LED_PIN_D13_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton button(Button1_PushButton_PIN_D4); // Initialize EasyButton instance void setup(void) { // put your setup code here, to run once: Serial.begin(115200); Serial.println(); Serial.println(">>> EasyButton pressed example <<<"); pinMode(Button1_PushButton_PIN_D4, INPUT_PULLUP); pinMode(visualFeedbackLED_LED_PIN_D13, OUTPUT); button.begin(); button.onPressed(onButtonPressed); } void loop(void) { // put your main code here, to run repeatedly: button.read(); // Continuously read the status of the button updateOutputs(); // Refresh output data } void onButtonPressed() { Serial.println("Button pressed"); visualFeedbackLED_LED_PIN_D13_rawData = !visualFeedbackLED_LED_PIN_D13_rawData; // Toggle LED state } void updateOutputs() { if (visualFeedbackLED_LED_PIN_D13_rawData) { // Blinking LED when button is pressed digitalWrite(visualFeedbackLED_LED_PIN_D13, HIGH); delay(500); digitalWrite(visualFeedbackLED_LED_PIN_D13, LOW); delay(500); } else { // Turn off LED when button is not pressed digitalWrite(visualFeedbackLED_LED_PIN_D13, LOW); } } /* 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)