Advertisement
pleasedontcode

LinearRailSlide rev_78

Nov 29th, 2023
78
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 22:19:26
  15.     - Source Code generated by: Francesco Alessandro
  16.  
  17. ********* Pleasedontcode.com **********/
  18.  
  19. /********* User code review feedback **********
  20. #### Feedback 1 ####
  21. - complete the code in according to system requirements.
  22. ********* User code review feedback **********/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h>
  26. #include <Stepper.h>
  27.  
  28. /****** SYSTEM REQUIREMENT 1 *****/
  29. /* A stepper motor drives a 200 mm length linear rail */
  30. /* slide. The motor performs 100 steps/revolution. */
  31. /* Steps per mm of Lead screw is 10mm. */
  32. /****** SYSTEM REQUIREMENT 2 *****/
  33. /* Perform a complete continuous travel of 200mm from */
  34. /* right to left in 12 hours. Then go back from left */
  35. /* to right again in 12 hours. */
  36.  
  37. /****** FUNCTION PROTOTYPES *****/
  38. void setup(void);
  39. void loop(void);
  40.  
  41. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  42. const uint8_t STEPPER_PIN_1_PIN_D2 = 2;
  43. const uint8_t STEPPER_PIN_2_PIN_D3 = 3;
  44. const uint8_t STEPPER_PIN_3_PIN_D4 = 4;
  45. const uint8_t STEPPER_PIN_4_PIN_D5 = 5;
  46.  
  47. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  48. const int stepsPerRevolution = 100;
  49. Stepper myStepper(stepsPerRevolution, STEPPER_PIN_1_PIN_D2, STEPPER_PIN_2_PIN_D3, STEPPER_PIN_3_PIN_D4, STEPPER_PIN_4_PIN_D5);
  50.  
  51. void setup(void)
  52. {
  53.   // put your setup code here, to run once:
  54.   pinMode(STEPPER_PIN_1_PIN_D2, OUTPUT);
  55.   pinMode(STEPPER_PIN_2_PIN_D3, OUTPUT);
  56.   pinMode(STEPPER_PIN_3_PIN_D4, OUTPUT);
  57.   pinMode(STEPPER_PIN_4_PIN_D5, OUTPUT);
  58.  
  59.   myStepper.setSpeed(100);
  60. }
  61.  
  62. void loop(void)
  63. {
  64.   // put your main code here, to run repeatedly:
  65.   myStepper.step(stepsPerRevolution); // Move the stepper motor by one revolution
  66.   delay(60000); // Delay for 1 minute
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement