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: **LED Toggle**
- - Source Code NOT compiled for: ESP8266 NodeMCU V1.0
- - Source Code created on: 2025-02-25 02:42:11
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* turns on and turn off the LED when the button is */
- /* pushed */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- void buttonPressed(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t button_PushButton_PIN_D1 = 1;
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t led_LED_PIN_D2 = 2;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool led_LED_PIN_D2_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float led_LED_PIN_D2_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton button(button_PushButton_PIN_D1); // Instantiate EasyButton object
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(led_LED_PIN_D2, OUTPUT);
- button.begin(); // Initialize the button
- button.onPressed(buttonPressed); // Attach the button pressed event
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- button.read(); // Read the button state
- updateOutputs(); // Refresh output data
- }
- void updateOutputs()
- {
- digitalWrite(led_LED_PIN_D2, led_LED_PIN_D2_rawData);
- }
- void buttonPressed()
- {
- // Toggle the LED state
- led_LED_PIN_D2_rawData = !led_LED_PIN_D2_rawData;
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement