Advertisement
pleasedontcode

"PWM Setup" rev_01

Feb 23rd, 2024
75
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: "PWM Setup"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-02-23 08:29:45
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Speed control of AC motor, by varying the PWM duty */
  21.     /* cycles */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h> // Include the Arduino library
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30. void updateOutputs(void);
  31.  
  32. /***** DEFINITION OF PWM OUTPUT PINS *****/
  33. const uint8_t PWM1_PIN_D3 = 3;
  34.  
  35. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  36. /***** Used to store raw data *****/
  37. uint8_t PWM1_PIN_D3_rawData = 0;
  38.  
  39. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  40. /***** Used to store data after characteristic curve transformation *****/
  41. float PWM1_PIN_D3_phyData = 0.0;
  42.  
  43. void setup(void) {
  44.     // Set the PWM1_PIN_D3 pin as an output
  45.     pinMode(PWM1_PIN_D3, OUTPUT);
  46. }
  47.  
  48. void loop(void) {
  49.     // Put your main code here, to run repeatedly:
  50.    
  51.     updateOutputs(); // Refresh output data
  52. }
  53.  
  54. void updateOutputs(void) {
  55.     // Update the analog output on PWM1_PIN_D3 based on the raw data value
  56.     analogWrite(PWM1_PIN_D3, PWM1_PIN_D3_rawData);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement