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: Button LED - Source Code compiled for: Arduino Uno - Source Code created on: 2024-04-06 11:49:46 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Brighten LED to full bright when myButton1 or */ /* myButton2 is pressed and kept pressed. Dim LED1 */ /* when myButton1 or myButton2 is pressed and kept */ /* pressed. Turn LED1 off when either button is */ /* pressed and un-pressed quickly */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
//https://github.com/evert-arias/EasyButton /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t myButton1_PushButton_PIN_D2 = 2; const uint8_t myButton2_PushButton_PIN_D3 = 3; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t LED1_LED_PIN_D4 = 4; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool LED1_LED_PIN_D4_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float LED1_LED_PIN_D4_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton myButton1(myButton1_PushButton_PIN_D2); EasyButton myButton2(myButton2_PushButton_PIN_D3); bool myButton1Pressed = false; bool myButton2Pressed = false; void setup(void) { // put your setup code here, to run once: pinMode(myButton1_PushButton_PIN_D2, INPUT_PULLUP); pinMode(myButton2_PushButton_PIN_D3, INPUT_PULLUP); pinMode(LED1_LED_PIN_D4, OUTPUT); myButton1.begin(); myButton2.begin(); } void loop(void) { // put your main code here, to run repeatedly: myButton1.read(); myButton2.read(); if (myButton1.isPressed()) { myButton1Pressed = true; } if (myButton2.isPressed()) { myButton2Pressed = true; } if (myButton1.isReleased() && myButton2.isReleased()) { myButton1Pressed = false; myButton2Pressed = false; } updateOutputs(); // Refresh output data } void updateOutputs() { if (myButton1Pressed || myButton2Pressed) { LED1_LED_PIN_D4_rawData = 1; // Set LED1 to full bright } else { LED1_LED_PIN_D4_rawData = 0; // Set LED1 to off } digitalWrite(LED1_LED_PIN_D4, LED1_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)