CCCPaste

Motor Control rev_01

/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: Motor Control
	- Source Code compiled for: Arduino Mega
	- Source Code created on: 2024-01-16 09:45:37

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* move 18 motor in which 6 in left and 6 in right */
	/* and 6 in front and back */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include 

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* move 18 motor in which 6 in left and 6 in right */
/* and 6 in front and back */

/****** FUNCTION PROTOTYPES *****/
void setup();
void loop();

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t leftMotorPins[6] = {3, 4, 5, 6, 7, 8};
const uint8_t rightMotorPins[6] = {9, 10, 11, 12, 13, 14};
const uint8_t frontMotorPins[6] = {15, 16, 17, 18, 19, 20};
const uint8_t backMotorPins[6] = {21, 22, 23, 24, 25, 26};

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton button(leftMotorPins[0]);

void setup() {
  // put your setup code here, to run once:
  for (int i = 0; i < 6; i++) {
    pinMode(leftMotorPins[i], OUTPUT);
    pinMode(rightMotorPins[i], OUTPUT);
    pinMode(frontMotorPins[i], OUTPUT);
    pinMode(backMotorPins[i], OUTPUT);
  }

  button.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
  if (button.read()) {
    // Move motors in the desired direction
    for (int i = 0; i < 6; i++) {
      digitalWrite(leftMotorPins[i], HIGH);
      digitalWrite(rightMotorPins[i], HIGH);
      digitalWrite(frontMotorPins[i], HIGH);
      digitalWrite(backMotorPins[i], HIGH);
    }
    delay(1000); // Adjust the delay as needed

    // Stop the motors
    for (int i = 0; i < 6; i++) {
      digitalWrite(leftMotorPins[i], LOW);
      digitalWrite(rightMotorPins[i], LOW);
      digitalWrite(frontMotorPins[i], LOW);
      digitalWrite(backMotorPins[i], LOW);
    }
    delay(1000); // Adjust the delay as needed
  }
}