Advertisement
pleasedontcode

Button Blink rev_03

Mar 4th, 2024
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: Button Blink
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-03-04 22:57:05
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* led turns on for 0,5s after activating a button */
  21.     /* and stays off until the button is deactivated */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h>
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30. void updateOutputs(void);
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t przycisk_PushButton_PIN_D2 = 2;
  34.  
  35. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  36. const uint8_t lampka_LED_PIN_D3 = 3;
  37.  
  38. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  39. bool lampka_LED_PIN_D3_rawData = 0;
  40.  
  41. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  42. float lampka_LED_PIN_D3_phyData = 0.0;
  43.  
  44. void setup(void)
  45. {
  46.   // put your setup code here, to run once:
  47.   pinMode(przycisk_PushButton_PIN_D2, INPUT_PULLUP);
  48.   pinMode(lampka_LED_PIN_D3, OUTPUT);
  49. }
  50.  
  51. void loop(void)
  52. {
  53.   // put your main code here, to run repeatedly:
  54.   if (digitalRead(przycisk_PushButton_PIN_D2) == LOW) {
  55.     lampka_LED_PIN_D3_rawData = 1; // Activate the LED
  56.     updateOutputs(); // Refresh output data
  57.     delay(500); // Wait for 500 milliseconds (0.5 seconds)
  58.     lampka_LED_PIN_D3_rawData = 0; // Deactivate the LED
  59.     updateOutputs(); // Refresh output data
  60.   }
  61. }
  62.  
  63. void updateOutputs()
  64. {
  65.   digitalWrite(lampka_LED_PIN_D3, lampka_LED_PIN_D3_rawData);
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement