Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Servo Control
- - Source Code NOT compiled for: Arduino Nano
- - Source Code created on: 2024-10-19 12:08:44
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* start servos with throttles minimum for 10s, then */
- /* start at 25% power for 45s and after that turn off */
- /* servos */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Servo.h> //https://github.com/arduino-libraries/Servo
- #include <ESC.h> //https://github.com/RB-ENantel/RC_ESC
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- /***** DEFINITION OF PWM OUTPUT PINS *****/
- const uint8_t motor_Servomotor_PWMSignal_PIN_D3 = 3;
- const uint8_t motor2_Servomotor_PWMSignal_PIN_D5 = 5;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- uint8_t motor_Servomotor_PWMSignal_PIN_D3_rawData = 0; // Minimum throttle
- uint8_t motor2_Servomotor_PWMSignal_PIN_D5_rawData = 0; // Minimum throttle
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Create Servo objects for each motor
- Servo motorServo1; // Servo object for motor on pin D3
- Servo motorServo2; // Servo object for motor on pin D5
- void setup(void)
- {
- // Attach the Servo objects to the corresponding PWM pins
- motorServo1.attach(motor_Servomotor_PWMSignal_PIN_D3);
- motorServo2.attach(motor2_Servomotor_PWMSignal_PIN_D5);
- // Start servos with minimum throttle
- motor_Servomotor_PWMSignal_PIN_D3_rawData = 0; // Minimum throttle
- motor2_Servomotor_PWMSignal_PIN_D5_rawData = 0; // Minimum throttle
- updateOutputs(); // Write minimum throttle to servos
- delay(10000); // Wait for 10 seconds
- // Start at 25% power (assuming 0-180 degrees, 25% is 45 degrees)
- motor_Servomotor_PWMSignal_PIN_D3_rawData = 45; // 25% power
- motor2_Servomotor_PWMSignal_PIN_D5_rawData = 45; // 25% power
- updateOutputs(); // Write 25% power to servos
- delay(45000); // Wait for 45 seconds
- // Turn off servos
- motor_Servomotor_PWMSignal_PIN_D3_rawData = 0; // Minimum throttle
- motor2_Servomotor_PWMSignal_PIN_D5_rawData = 0; // Minimum throttle
- updateOutputs(); // Write minimum throttle to servos
- }
- void loop(void)
- {
- // No need to do anything in loop since all actions are in setup
- }
- void updateOutputs()
- {
- // Write the raw data to the Servo objects
- motorServo1.write(motor_Servomotor_PWMSignal_PIN_D3_rawData);
- motorServo2.write(motor2_Servomotor_PWMSignal_PIN_D5_rawData);
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement