Advertisement
pleasedontcode

Servo Control rev_03

May 14th, 2024
489
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-05-14 15:09: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. /****** SYSTEM REQUIREMENT 2 *****/
  23.     /* 4 motors and should me controled by serial */
  24.     /* moniters */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <Servo.h>  //https://github.com/arduino-libraries/Servo
  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 no_Servomotor_PWMSignal_PIN_D3 = 3;
  37. const uint8_t no_Servomotor_PWMSignal_PIN_D5 = 5;
  38.  
  39. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  40. /***** used to store raw data *****/
  41. uint8_t no_Servomotor_PWMSignal_PIN_D3_rawData = 0;
  42. uint8_t no_Servomotor_PWMSignal_PIN_D5_rawData = 0;
  43.  
  44. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  45. /***** used to store data after characteristic curve transformation *****/
  46. float no_Servomotor_PWMSignal_PIN_D3_phyData = 0.0;
  47. float no_Servomotor_PWMSignal_PIN_D5_phyData = 0.0;
  48.  
  49. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  50. Servo servo1; // Servo object for PWM signal on pin D3
  51. Servo servo2; // Servo object for PWM signal on pin D5
  52.  
  53. void setup(void)
  54. {
  55.     // put your setup code here, to run once:
  56.     servo1.attach(no_Servomotor_PWMSignal_PIN_D3);
  57.     servo2.attach(no_Servomotor_PWMSignal_PIN_D5);
  58. }
  59.  
  60. void loop(void)
  61. {
  62.     // put your main code here, to run repeatedly:
  63.     updateOutputs(); // Refresh output data
  64. }
  65.  
  66. void updateOutputs()
  67. {
  68.     servo1.write(no_Servomotor_PWMSignal_PIN_D3_rawData);
  69.     servo2.write(no_Servomotor_PWMSignal_PIN_D5_rawData);
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement