Advertisement
pleasedontcode

LinearRailSlide rev_70

Nov 29th, 2023
87
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: LinearRailSlide
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-29 21:50:18
  15.     - Source Code generated by: Francesco Alessandro
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <AccelStepper.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* Perform a complete continuous travel from right to */
  24. /* left in 12 hours. Then go back from left to right */
  25. /* again in 12 hours. The movement shall be */
  26. /* continuous in 12 hours. Do not use delay function. */
  27.  
  28. /****** SYSTEM REQUIREMENT 2 *****/
  29. /* A stepper motor drives a 200 mm length linear rail */
  30. /* slide. The motor performs 100 steps/revolution. */
  31. /* Step per mm of Lead screw is 10mm. */
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36.  
  37. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  38. const uint8_t stepper_A4988StepperMotorDriver_STEP_PIN_D8 = 8;
  39. const uint8_t stepper_A4988StepperMotorDriver_DIR_PIN_D9 = 9;
  40.  
  41. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  42. AccelStepper stepper(1, stepper_A4988StepperMotorDriver_STEP_PIN_D8, stepper_A4988StepperMotorDriver_DIR_PIN_D9);
  43.  
  44. void setup(void)
  45. {
  46.   // put your setup code here, to run once:
  47.  
  48.   pinMode(stepper_A4988StepperMotorDriver_STEP_PIN_D8, OUTPUT);
  49.   pinMode(stepper_A4988StepperMotorDriver_DIR_PIN_D9, OUTPUT);
  50.  
  51.   // Set up the stepper motor parameters
  52.   stepper.setMaxSpeed(100);
  53.   stepper.setAcceleration(100);
  54.   stepper.setSpeed(100);
  55. }
  56.  
  57. void loop(void)
  58. {
  59.   // put your main code here, to run repeatedly:
  60.  
  61.   // Move the stepper motor continuously from right to left
  62.   stepper.move(2000);
  63.   stepper.run();
  64.  
  65.   // Move the stepper motor continuously from left to right
  66.   stepper.move(-2000);
  67.   stepper.run();
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement