Advertisement
pleasedontcode

Tech_arduinov1 rev_27

Oct 14th, 2023
95
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: Tech_arduinov1
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-10-14 21:37:56
  15.     - Source Code generated by: AlexWind
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* turn on the light when you click the button */
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28.  
  29. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  30. const uint8_t Tech_inc_PushButton_PIN_D2 = 2;
  31. const uint8_t Tech_inc_LED_PIN_D13 = 13;
  32.  
  33. // Create an instance of the EasyButton class
  34. EasyButton button(Tech_inc_PushButton_PIN_D2);
  35.  
  36. void setup(void)
  37. {
  38.   // Set the LED pin as an output
  39.   pinMode(Tech_inc_LED_PIN_D13, OUTPUT);
  40.  
  41.   // Initialize the button
  42.   button.begin();
  43. }
  44.  
  45. void loop(void)
  46. {
  47.   // Update the button state
  48.   button.update();
  49.  
  50.   // Check if the button is pressed
  51.   if (button.isPressed())
  52.   {
  53.     // Turn on the LED
  54.     digitalWrite(Tech_inc_LED_PIN_D13, HIGH);
  55.   }
  56.   else
  57.   {
  58.     // Turn off the LED
  59.     digitalWrite(Tech_inc_LED_PIN_D13, LOW);
  60.   }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement