Advertisement
pleasedontcode

"Servo Control" rev_01

Mar 20th, 2024
97
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: "Servo Control"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-03-20 11:46:52
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* rotate clockwise first */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Servo.h> // Include the Servo library
  25.  
  26. /****** SYSTEM REQUIREMENTS *****/
  27. /****** SYSTEM REQUIREMENT 1 *****/
  28. /* rotate clockwise first */
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33. void updateOutputs(void);
  34.  
  35. /***** DEFINITION OF PWM OUTPUT PINS *****/
  36. const uint8_t a_Servomotor_PWMSignal_PIN_D3 = 3;
  37. const uint8_t a_Servomotor_PWMSignal_PIN_D5 = 5;
  38.  
  39. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  40. /***** used to store raw data *****/
  41. uint8_t a_Servomotor_PWMSignal_PIN_D3_rawData = 0;
  42. uint8_t a_Servomotor_PWMSignal_PIN_D5_rawData = 0;
  43.  
  44. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  45. /***** used to store data after characteristic curve transformation *****/
  46. float a_Servomotor_PWMSignal_PIN_D3_phyData = 0.0;
  47. float a_Servomotor_PWMSignal_PIN_D5_phyData = 0.0;
  48.  
  49. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  50. Servo servo_D3; // Create an instance of the Servo class for pin D3
  51. Servo servo_D5; // Create an instance of the Servo class for pin D5
  52.  
  53. void setup(void)
  54. {
  55.   // put your setup code here, to run once:
  56.  
  57.   pinMode(a_Servomotor_PWMSignal_PIN_D3, OUTPUT); // Set pin D3 as output
  58.   pinMode(a_Servomotor_PWMSignal_PIN_D5, OUTPUT); // Set pin D5 as output
  59.  
  60.   servo_D3.attach(a_Servomotor_PWMSignal_PIN_D3); // Attach servo_D3 to pin D3
  61.   servo_D5.attach(a_Servomotor_PWMSignal_PIN_D5); // Attach servo_D5 to pin D5
  62.  
  63.   servo_D3.write(0); // Rotate servo_D3 clockwise to 0 degrees
  64.   servo_D5.write(0); // Rotate servo_D5 clockwise to 0 degrees
  65.   delay(1000); // Delay for 1 second
  66. }
  67.  
  68. void loop(void)
  69. {
  70.   // put your main code here, to run repeatedly:
  71.  
  72.   updateOutputs(); // Refresh output data
  73. }
  74.  
  75. void updateOutputs()
  76. {
  77.   servo_D3.write(a_Servomotor_PWMSignal_PIN_D3_rawData); // Set servo_D3 position based on a_Servomotor_PWMSignal_PIN_D3_rawData
  78.   servo_D5.write(a_Servomotor_PWMSignal_PIN_D5_rawData); // Set servo_D5 position based on a_Servomotor_PWMSignal_PIN_D5_rawData
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement