Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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-08 18:25:10
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* I have a push button to digital pin 4 and a led on */
- /* pin 8. Pin 8 high turns on the light. When the */
- /* button is pressed once I want to turn light on. */
- /* Holding the button will start running it and let */
- /* it run as long as pr */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t startButton_PushButton_PIN_D4 = 4;
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t ledLight_LED_PIN_D8 = 8;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool ledLight_LED_PIN_D8_rawData = LOW;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton startButton(startButton_PushButton_PIN_D4);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(ledLight_LED_PIN_D8, OUTPUT);
- startButton.begin();
- startButton.onPressed([]() {
- ledLight_LED_PIN_D8_rawData = HIGH;
- });
- Serial.begin(115200);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- startButton.read();
- if (startButton.isPressed()) {
- digitalWrite(ledLight_LED_PIN_D8, HIGH);
- } else {
- digitalWrite(ledLight_LED_PIN_D8, LOW);
- }
- }
- void updateOutputs()
- {
- digitalWrite(ledLight_LED_PIN_D8, ledLight_LED_PIN_D8_rawData);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement