Advertisement
pleasedontcode

"Stepper Motor Loop" rev_01

Dec 28th, 2023
81
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: "Stepper Motor Loop"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-28 07:23:57
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Programme an arduino Uno to use two stepper motors */
  21.     /* with driver, A4988 and CNC shield to achieve */
  22.     /* motion, 360° with one second delay simultaneously */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Arduino.h>
  27. #include <Stepper.h>
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  34. const uint8_t Motordriver_A4988StepperMotorDriver_MS3_PIN_D5 = 5;
  35. const uint8_t Motordriver_A4988StepperMotorDriver_DIR_PIN_D9 = 9;
  36.  
  37. /***** DEFINITION OF STEPPER MOTOR OBJECTS *****/
  38. Stepper motor1(200, Motordriver_A4988StepperMotorDriver_DIR_PIN_D9, Motordriver_A4988StepperMotorDriver_MS3_PIN_D5);
  39. Stepper motor2(200, Motordriver_A4988StepperMotorDriver_DIR_PIN_D9, Motordriver_A4988StepperMotorDriver_MS3_PIN_D5);
  40.  
  41. void setup(void)
  42. {
  43.     // Set the speed of the motors to 360 steps per minute
  44.     motor1.setSpeed(360);
  45.     motor2.setSpeed(360);
  46. }
  47.  
  48. void loop(void)
  49. {
  50.     // Move both motors 360° in one direction
  51.     motor1.step(200);
  52.     motor2.step(200);
  53.  
  54.     // Delay for 1 second
  55.     delay(1000);
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement