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: LinearRailSlide
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-11-29 22:24:16
- - Source Code generated by: Francesco Alessandro
- ********* Pleasedontcode.com **********/
- /********* User code review feedback **********
- #### Feedback 1 ####
- - the delay wait 12 hours to perform just only 10 steps. 12hours i
- s the time to have a complete travel.
- ********* User code review feedback **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <Stepper.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- /* A stepper motor drives a 200 mm length linear rail */
- /* slide. The motor performs 100 steps/revolution. */
- /* Step per mm of Lead screw is 10mm. */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* Perform a complete continuous travel of 200mm from */
- /* right to left in 12 hours. Then go back from left */
- /* to right again in 12 hours. */
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t STEPPER_PIN_1_PIN_D2 = 2;
- const uint8_t STEPPER_PIN_2_PIN_D3 = 3;
- const uint8_t STEPPER_PIN_3_PIN_D4 = 4;
- const uint8_t STEPPER_PIN_4_PIN_D5 = 5;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- const int stepsPerRevolution = 100;
- Stepper myStepper(stepsPerRevolution, STEPPER_PIN_1_PIN_D2, STEPPER_PIN_2_PIN_D3, STEPPER_PIN_3_PIN_D4, STEPPER_PIN_4_PIN_D5);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(STEPPER_PIN_1_PIN_D2, OUTPUT);
- pinMode(STEPPER_PIN_2_PIN_D3, OUTPUT);
- pinMode(STEPPER_PIN_3_PIN_D4, OUTPUT);
- pinMode(STEPPER_PIN_4_PIN_D5, OUTPUT);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Perform a complete continuous travel of 200mm from right to left in 12 hours
- for (int i = 0; i < 200; i++)
- {
- myStepper.setSpeed(100); // Set the speed of the stepper motor (adjust as needed)
- myStepper.step(10); // Move the stepper motor 10 steps (equivalent to 1mm)
- delay(4320000); // Delay for 12 hours divided by 10 steps (adjust as needed)
- }
- // Go back from left to right again in 12 hours
- for (int i = 0; i < 200; i++)
- {
- myStepper.setSpeed(100); // Set the speed of the stepper motor (adjust as needed)
- myStepper.step(-10); // Move the stepper motor 10 steps backwards (equivalent to 1mm)
- delay(4320000); // Delay for 12 hours divided by 10 steps (adjust as needed)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement