Advertisement
pleasedontcode

LED Control rev_01

May 3rd, 2024
832
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-05-03 11:37:32
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* PWM CONTOLL */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28. void updateOutputs(void); // Added function prototype for updateOutputs
  29.  
  30. /***** DEFINITION OF ANALOG INPUT PINS *****/
  31. const uint8_t pot_Potentiometer_Vout_PIN_D4 = D4;
  32.  
  33. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  34. const uint8_t isik_LED_PIN_D13 = 13;
  35.  
  36. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  37. /***** used to store raw data *****/
  38. bool isik_LED_PIN_D13_rawData = 0;
  39.  
  40. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  41. /***** used to store data after characteristic curve transformation *****/
  42. float isik_LED_PIN_D13_phyData = 0.0;
  43.  
  44. void setup(void)
  45. {
  46.     // put your setup code here, to run once:
  47.     pinMode(pot_Potentiometer_Vout_PIN_D4, INPUT);
  48.     pinMode(isik_LED_PIN_D13, OUTPUT);
  49.  
  50.     // PWM CONTROL
  51.     // Set PWM frequency for LED control
  52.     ledcSetup(0, 5000, 8); // Configure PWM channel at 5 kHz with 8-bit resolution
  53.     ledcAttachPin(isik_LED_PIN_D13, 0); // Attach PWM channel to LED pin
  54. }
  55.  
  56. void loop(void)
  57. {
  58.     // put your main code here, to run repeatedly:
  59.     updateOutputs(); // Refresh output data
  60. }
  61.  
  62. void updateOutputs()
  63. {
  64.     // Update LED brightness using PWM
  65.     ledcWrite(0, isik_LED_PIN_D13_rawData); // Set PWM duty cycle based on raw data
  66. }
  67.  
  68. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement