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: Toggle Button - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-05-03 07:29:03 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* turn on when the push button is on */ /****** SYSTEM REQUIREMENT 2 *****/ /* turn on when the push button is on */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
/****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t LED_LED_PIN_D4 = 4; const uint8_t PUSH_BUTTON_PIN = 2; // Define the push button pin /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ bool LED_LED_PIN_D4_rawData = false; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ float LED_LED_PIN_D4_phyData = 0.0; // Create an EasyButton object for the push button EasyButton pushButton(PUSH_BUTTON_PIN); void setup(void) { // put your setup code here, to run once: pinMode(LED_LED_PIN_D4, OUTPUT); // Initialize the push button pushButton.begin(); } void loop(void) { // put your main code here, to run repeatedly: updateOutputs(); // Refresh output data // Update the push button state pushButton.update(); // Check if the push button is pressed if (pushButton.read()) { // Toggle the LED state when the push button is pressed LED_LED_PIN_D4_rawData = !LED_LED_PIN_D4_rawData; } } void updateOutputs(void) { digitalWrite(LED_LED_PIN_D4, LED_LED_PIN_D4_rawData); }
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)