Advertisement
pleasedontcode

Button LED rev_01

Dec 18th, 2023
82
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: Button LED
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-18 10:09:29
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Turn on when button on turn off when bottom off */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* Turn on when button on turn off when bottom off */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Arduino.h>
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  33. const uint8_t Prajwal_LED_PIN_D2 = 2; // Define the digital output pin for the LED
  34. const uint8_t buttonPin = 3; // Define the digital input pin for the button
  35.  
  36. void setup(void)
  37. {
  38.     // put your setup code here, to run once:
  39.     pinMode(Prajwal_LED_PIN_D2, OUTPUT); // Set the LED pin as output
  40.     pinMode(buttonPin, INPUT_PULLUP); // Set the button pin as input with internal pull-up resistor
  41. }
  42.  
  43. void loop(void)
  44. {
  45.     // put your main code here, to run repeatedly:
  46.     // Implement the system requirements
  47.  
  48.     /****** SYSTEM REQUIREMENT 1 *****/
  49.     /* Turn on when button is pressed, turn off when button is released */
  50.     if (digitalRead(buttonPin) == LOW) {
  51.         digitalWrite(Prajwal_LED_PIN_D2, HIGH); // Turn on the LED
  52.     } else {
  53.         digitalWrite(Prajwal_LED_PIN_D2, LOW); // Turn off the LED
  54.     }
  55.  
  56.     /****** SYSTEM REQUIREMENT 2 *****/
  57.     /* Turn on when button is pressed, turn off when button is released */
  58.     if (digitalRead(buttonPin) == LOW) {
  59.         // Implement the code for system requirement 2 here
  60.     }
  61.  
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement