Advertisement
pleasedontcode

Servo Control rev_01

Apr 24th, 2024
43
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 NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-04-24 06:08:16
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* move a robotic arm according data from huskylens */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Servo.h>  // Include the Servo library
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29. void updateOutputs(void);  // Add function prototype for updateOutputs
  30.  
  31. /***** DEFINITION OF PWM OUTPUT PINS *****/
  32. const uint8_t servo_Servomotor_PWMSignal_PIN_D3 = 3;
  33. const uint8_t servo2_Servomotor_PWMSignal_PIN_D5 = 5;
  34. const uint8_t Servomotor_PWMSignal_PIN_D6 = 6;  // Corrected variable name
  35. const uint8_t Servomotor_PWMSignal_PIN_D9 = 9;  // Corrected variable name
  36. const uint8_t Servomotor_PWMSignal_PIN_D10 = 10;  // Corrected variable name
  37.  
  38. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  39. uint8_t servo_Servomotor_PWMSignal_PIN_D3_rawData = 0;
  40. uint8_t servo2_Servomotor_PWMSignal_PIN_D5_rawData = 0;
  41. uint8_t Servomotor_PWMSignal_PIN_D6_rawData = 0;  // Corrected variable name
  42. uint8_t Servomotor_PWMSignal_PIN_D9_rawData = 0;  // Corrected variable name
  43. uint8_t Servomotor_PWMSignal_PIN_D10_rawData = 0;  // Corrected variable name
  44.  
  45. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  46. float servo_Servomotor_PWMSignal_PIN_D3_phyData = 0.0;
  47. float servo2_Servomotor_PWMSignal_PIN_D5_phyData = 0.0;
  48. float Servomotor_PWMSignal_PIN_D6_phyData = 0.0;  // Corrected variable name
  49. float Servomotor_PWMSignal_PIN_D9_phyData = 0.0;  // Corrected variable name
  50. float Servomotor_PWMSignal_PIN_D10_phyData = 0.0;  // Corrected variable name
  51.  
  52. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  53. Servo myservo;  // Create Servo object instance
  54.  
  55. void setup(void)
  56. {
  57.   // put your setup code here, to run once:
  58.   myservo.attach(Servomotor_PWMSignal_PIN_D9);  // Attach Servo object to pin 9
  59.  
  60.   pinMode(servo_Servomotor_PWMSignal_PIN_D3, OUTPUT);
  61.   pinMode(servo2_Servomotor_PWMSignal_PIN_D5, OUTPUT);
  62.   pinMode(Servomotor_PWMSignal_PIN_D6, OUTPUT);
  63.   pinMode(Servomotor_PWMSignal_PIN_D10, OUTPUT);
  64. }
  65.  
  66. void loop(void)
  67. {
  68.   // put your main code here, to run repeatedly:
  69.   updateOutputs();  // Refresh output data
  70. }
  71.  
  72. void updateOutputs()
  73. {
  74.   analogWrite(servo_Servomotor_PWMSignal_PIN_D3, servo_Servomotor_PWMSignal_PIN_D3_rawData);
  75.   analogWrite(servo2_Servomotor_PWMSignal_PIN_D5, servo2_Servomotor_PWMSignal_PIN_D5_rawData);
  76.   analogWrite(Servomotor_PWMSignal_PIN_D6, Servomotor_PWMSignal_PIN_D6_rawData);
  77.   analogWrite(Servomotor_PWMSignal_PIN_D10, Servomotor_PWMSignal_PIN_D10_rawData);
  78. }
  79.  
  80. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement