Advertisement
pleasedontcode

Project rev_01

Sep 25th, 2023
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Project
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-09-25 07:40:38
  15.     - Source Code generated by: Malik
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23.     /* Turns on & off LED when pressing a push button */
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28.  
  29. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  30. const uint8_t myButton_PushButton_PIN_D2 = 2;
  31.  
  32. // Define LED pin
  33. const uint8_t myLED_PIN = 13;
  34.  
  35. // Create an instance of EasyButton
  36. EasyButton myButton(myButton_PushButton_PIN_D2);
  37.  
  38. void setup(void)
  39. {
  40.     // Set LED pin as output
  41.     pinMode(myLED_PIN, OUTPUT);
  42.  
  43.     // Initialize the button
  44.     myButton.begin();
  45. }
  46.  
  47. void loop(void)
  48. {
  49.     // Update the button state
  50.     myButton.update();
  51.  
  52.     // Check if the button is pressed
  53.     if (myButton.isPressed())
  54.     {
  55.         // Toggle the LED state
  56.         digitalWrite(myLED_PIN, !digitalRead(myLED_PIN));
  57.     }
  58.  
  59.     // Delay to avoid rapid button presses
  60.     delay(100);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement