Advertisement
pleasedontcode

LinearRailSlide rev_69

Nov 29th, 2023
85
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:48:23
  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. // Create an instance of the AccelStepper class with the required pins and motor type
  43. AccelStepper stepper(AccelStepper::FULL4WIRE, stepper_A4988StepperMotorDriver_STEP_PIN_D8, stepper_A4988StepperMotorDriver_DIR_PIN_D9);
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.  
  49.   // Set the pin modes for the stepper motor driver pins
  50.   pinMode(stepper_A4988StepperMotorDriver_STEP_PIN_D8, OUTPUT);
  51.   pinMode(stepper_A4988StepperMotorDriver_DIR_PIN_D9, OUTPUT);
  52.  
  53.   // Set the maximum speed and initial speed of the stepper motor
  54.   stepper.setMaxSpeed(1000);
  55.   stepper.setSpeed(50);
  56. }
  57.  
  58. void loop(void)
  59. {
  60.   // put your main code here, to run repeatedly:
  61.  
  62.   // Run the stepper motor at the defined speed
  63.   stepper.runSpeed();
  64. }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement