Advertisement
pleasedontcode

Dual Servo Control rev_01

May 14th, 2024
465
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: Dual Servo Control
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-14 15:07:46
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* code for controlling rc car with serial monitoring */
  21.     /* arduino */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Servo.h> //https://github.com/arduino-libraries/Servo
  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 no_Servomotor_PWMSignal_PIN_D3 = 3;
  34. const uint8_t no_Servomotor_PWMSignal_PIN_D5 = 5;
  35.  
  36. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  37. /***** used to store raw data *****/
  38. uint8_t no_Servomotor_PWMSignal_PIN_D3_rawData = 0;
  39. uint8_t no_Servomotor_PWMSignal_PIN_D5_rawData = 0;
  40.  
  41. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  42. /***** used to store data after characteristic curve transformation *****/
  43. float no_Servomotor_PWMSignal_PIN_D3_phyData = 0.0;
  44. float no_Servomotor_PWMSignal_PIN_D5_phyData = 0.0;
  45.  
  46. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  47. Servo servo1; // Create a Servo object for servo motor 1
  48. Servo servo2; // Create a Servo object for servo motor 2
  49.  
  50. void setup(void)
  51. {
  52.     // put your setup code here, to run once:
  53.     servo1.attach(no_Servomotor_PWMSignal_PIN_D3); // Attach servo1 to pin D3
  54.     servo2.attach(no_Servomotor_PWMSignal_PIN_D5); // Attach servo2 to pin D5
  55. }
  56.  
  57. void loop(void)
  58. {
  59.     // put your main code here, to run repeatedly:
  60.     updateOutputs(); // Refresh output data
  61. }
  62.  
  63. void updateOutputs()
  64. {
  65.     servo1.write(no_Servomotor_PWMSignal_PIN_D3_rawData); // Set position of servo1
  66.     servo2.write(no_Servomotor_PWMSignal_PIN_D5_rawData); // Set position of servo2
  67. }
  68.  
  69. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement