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: motor_test
- - Source Code created on: 2024-04-01 14:25:47
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* turn 180 degrees then disable motor */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Servo.h> // Servo library for the servo motor
- #include <TinyStepper_28BYJ_48.h> // Stepper library for the stepper motor
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- /***** DEFINITION OF PWM OUTPUT PINS *****/
- const uint8_t motor1_Servomotor_PWMSignal_PIN_D3 = 3;
- /***** DEFINITION OF STEPPER OUTPUT PINS *****/
- const int MOTOR_IN1_PIN = 11;
- const int MOTOR_IN2_PIN = 10;
- const int MOTOR_IN3_PIN = 6;
- const int MOTOR_IN4_PIN = 5;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- uint8_t motor1_Servomotor_PWMSignal_PIN_D3_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float motor1_Servomotor_PWMSignal_PIN_D3_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Servo motor1_Servomotor;
- TinyStepper_28BYJ_48 stepper; // Instantiate the stepper object
- void setup(void) {
- // put your setup code here, to run once:
- motor1_Servomotor.attach(motor1_Servomotor_PWMSignal_PIN_D3);
- stepper.connectToPins(MOTOR_IN1_PIN, MOTOR_IN2_PIN, MOTOR_IN3_PIN, MOTOR_IN4_PIN); // Connect the stepper motor to the pins
- }
- void loop(void) {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- // System Requirement 1: Turn 180 degrees then disable motor
- motor1_Servomotor.write(180);
- delay(1000);
- motor1_Servomotor.detach();
- // Add your stepper motor code here
- }
- void updateOutputs() {
- motor1_Servomotor.write(motor1_Servomotor_PWMSignal_PIN_D3_rawData);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement