Advertisement
pleasedontcode

Dual Servo Control rev_02

May 14th, 2024
481
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 compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-14 15:08: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.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Servo.h> //https://github.com/arduino-libraries/Servo
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31. void updateOutputs(void);
  32.  
  33. /***** DEFINITION OF PWM OUTPUT PINS *****/
  34. const uint8_t no_Servomotor_PWMSignal_PIN_D3 = 3;
  35. const uint8_t no_Servomotor_PWMSignal_PIN_D5 = 5;
  36.  
  37. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  38. /***** used to store raw data *****/
  39. uint8_t no_Servomotor_PWMSignal_PIN_D3_rawData = 0;
  40. uint8_t no_Servomotor_PWMSignal_PIN_D5_rawData = 0;
  41.  
  42. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  43. /***** used to store data after characteristic curve transformation *****/
  44. float no_Servomotor_PWMSignal_PIN_D3_phyData = 0.0;
  45. float no_Servomotor_PWMSignal_PIN_D5_phyData = 0.0;
  46.  
  47. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  48. Servo servo1; // Create a Servo object for servo motor 1
  49. Servo servo2; // Create a Servo object for servo motor 2
  50.  
  51. void setup(void)
  52. {
  53.     // put your setup code here, to run once:
  54.     servo1.attach(no_Servomotor_PWMSignal_PIN_D3); // Attach servo1 to pin D3
  55.     servo2.attach(no_Servomotor_PWMSignal_PIN_D5); // Attach servo2 to pin D5
  56. }
  57.  
  58. void loop(void)
  59. {
  60.     // put your main code here, to run repeatedly:
  61.     updateOutputs(); // Refresh output data
  62. }
  63.  
  64. void updateOutputs()
  65. {
  66.     servo1.write(no_Servomotor_PWMSignal_PIN_D3_rawData); // Set position of servo1
  67.     servo2.write(no_Servomotor_PWMSignal_PIN_D5_rawData); // Set position of servo2
  68. }
  69.  
  70. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement