Advertisement
pleasedontcode

**LED Control** rev_01

Nov 14th, 2024
78
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: **LED Control**
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-11-14 08:33:29
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The code shall be structured to facilitate easy */
  21.     /* modifications and enhancements, with clear */
  22.     /* function prototypes and comments guiding the */
  23.     /* implementation of additional features and */
  24.     /* libraries as needed. */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /* START CODE */
  28.  
  29. /****** DEFINITION OF LIBRARIES *****/
  30. #include <Arduino.h>
  31. #include <Wire.h>
  32. #include <SPI.h>
  33.  
  34. /****** FUNCTION PROTOTYPES *****/
  35. void setup(void);
  36. void loop(void);
  37. void updateOutputs(void);
  38.  
  39. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  40. const uint8_t led2_LED_PIN_D19 = 19;
  41. const uint8_t led1_LED_PIN_D21 = 21;
  42. const uint8_t led3_LED_PIN_D22 = 22;
  43. const uint8_t led4_LED_PIN_D23 = 23;
  44.  
  45. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  46. /***** used to store raw data *****/
  47. bool led2_LED_PIN_D19_rawData = 0;
  48. bool led1_LED_PIN_D21_rawData = 0;
  49. bool led3_LED_PIN_D22_rawData = 0;
  50. bool led4_LED_PIN_D23_rawData = 0;
  51.  
  52. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  53. /***** used to store data after characteristic curve transformation *****/
  54. float led2_LED_PIN_D19_phyData = 0.0;
  55. float led1_LED_PIN_D21_phyData = 0.0;
  56. float led3_LED_PIN_D22_phyData = 0.0;
  57. float led4_LED_PIN_D23_phyData = 0.0;
  58.  
  59. void setup(void)
  60. {
  61.     // Initialize digital pins as outputs
  62.     pinMode(led2_LED_PIN_D19, OUTPUT);
  63.     pinMode(led1_LED_PIN_D21, OUTPUT);
  64.     pinMode(led3_LED_PIN_D22, OUTPUT);
  65.     pinMode(led4_LED_PIN_D23, OUTPUT);
  66. }
  67.  
  68. void loop(void)
  69. {
  70.     // Refresh output data
  71.     updateOutputs();
  72. }
  73.  
  74. void updateOutputs(void)
  75. {
  76.     // Update the state of each LED based on raw data
  77.     digitalWrite(led2_LED_PIN_D19, led2_LED_PIN_D19_rawData);
  78.     digitalWrite(led1_LED_PIN_D21, led1_LED_PIN_D21_rawData);
  79.     digitalWrite(led3_LED_PIN_D22, led3_LED_PIN_D22_rawData);
  80.     digitalWrite(led4_LED_PIN_D23, led4_LED_PIN_D23_rawData);
  81. }
  82.  
  83. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement