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:03:45
- - Source Code generated by: Francesco Alessandro
- ********* Pleasedontcode.com **********/
- /********* User code review feedback **********
- #### Feedback 1 ####
- - complete the code in according to system requirements.
- ********* User code review feedback **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <Stepper.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Perform a complete continuous travel from right to */
- /* left in 12 hours. Then go back from left to right */
- /* again in 12 hours. The movement shall be */
- /* continuous in 12 hours. Do not use delay function. */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* 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. */
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t STEPPER_PIN_1 = 2;
- const uint8_t STEPPER_PIN_2 = 3;
- const uint8_t STEPPER_PIN_3 = 4;
- const uint8_t STEPPER_PIN_4 = 5;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Stepper myStepper(100, STEPPER_PIN_1, STEPPER_PIN_3, STEPPER_PIN_2, STEPPER_PIN_4);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(STEPPER_PIN_1, OUTPUT);
- pinMode(STEPPER_PIN_2, OUTPUT);
- pinMode(STEPPER_PIN_3, OUTPUT);
- pinMode(STEPPER_PIN_4, OUTPUT);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Add your code for the stepper motor movement
- /* Add code for continuous travel from right to left for 12 hours */
- /* Note: Do not use delay function */
- unsigned long startTime = millis();
- unsigned long elapsedTime = 0;
- while (elapsedTime < 12 * 60 * 60 * 1000) {
- myStepper.step(100);
- elapsedTime = millis() - startTime;
- }
- /* Add code for continuous travel from left to right for 12 hours */
- /* Note: Do not use delay function */
- startTime = millis();
- elapsedTime = 0;
- while (elapsedTime < 12 * 60 * 60 * 1000) {
- myStepper.step(-100);
- elapsedTime = millis() - startTime;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement