Advertisement
pleasedontcode

Motor Control rev_01

Jan 16th, 2024
68
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: Motor Control
  13.     - Source Code compiled for: Arduino Mega
  14.     - Source Code created on: 2024-01-16 09:45:37
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* move 18 motor in which 6 in left and 6 in right */
  21.     /* and 6 in front and back */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h>
  26. #include <EasyButton.h>
  27.  
  28. /****** SYSTEM REQUIREMENTS *****/
  29. /****** SYSTEM REQUIREMENT 1 *****/
  30. /* move 18 motor in which 6 in left and 6 in right */
  31. /* and 6 in front and back */
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup();
  35. void loop();
  36.  
  37. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  38. const uint8_t leftMotorPins[6] = {3, 4, 5, 6, 7, 8};
  39. const uint8_t rightMotorPins[6] = {9, 10, 11, 12, 13, 14};
  40. const uint8_t frontMotorPins[6] = {15, 16, 17, 18, 19, 20};
  41. const uint8_t backMotorPins[6] = {21, 22, 23, 24, 25, 26};
  42.  
  43. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  44. EasyButton button(leftMotorPins[0]);
  45.  
  46. void setup() {
  47.   // put your setup code here, to run once:
  48.   for (int i = 0; i < 6; i++) {
  49.     pinMode(leftMotorPins[i], OUTPUT);
  50.     pinMode(rightMotorPins[i], OUTPUT);
  51.     pinMode(frontMotorPins[i], OUTPUT);
  52.     pinMode(backMotorPins[i], OUTPUT);
  53.   }
  54.  
  55.   button.begin();
  56. }
  57.  
  58. void loop() {
  59.   // put your main code here, to run repeatedly:
  60.   if (button.read()) {
  61.     // Move motors in the desired direction
  62.     for (int i = 0; i < 6; i++) {
  63.       digitalWrite(leftMotorPins[i], HIGH);
  64.       digitalWrite(rightMotorPins[i], HIGH);
  65.       digitalWrite(frontMotorPins[i], HIGH);
  66.       digitalWrite(backMotorPins[i], HIGH);
  67.     }
  68.     delay(1000); // Adjust the delay as needed
  69.  
  70.     // Stop the motors
  71.     for (int i = 0; i < 6; i++) {
  72.       digitalWrite(leftMotorPins[i], LOW);
  73.       digitalWrite(rightMotorPins[i], LOW);
  74.       digitalWrite(frontMotorPins[i], LOW);
  75.       digitalWrite(backMotorPins[i], LOW);
  76.     }
  77.     delay(1000); // Adjust the delay as needed
  78.   }
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement