microrobotics icon

MDD20A Dual Channel 20A Motor Driver

microrobotics | PRO | 07/24/23 09:05:19 AM UTC | 0 ⭐ | 2847 👁️ | Never ⏰ | []
Arduino |

1.67 KB

|

None

|

0 👍

/

0 👎

/*
The MDD20A Dual Channel 20A Motor Driver from Cytron supports multiple communication interfaces including PWM, Analog, UART, I2C, and RC.
 
In this script, the motors will move forward at full speed for 2 seconds, stop for 2 seconds, move backward at full speed for 2 seconds, and then stop for 2 seconds. This cycle repeats indefinitely.
 
Remember to connect the GND of the driver to the GND of the Arduino, and to supply the driver with an appropriate power source.
 
The pin numbers in the script are placeholders, so ensure to replace them with the actual numbers according to your setup.
 
Let's provide an example of how to control the MDD20A motor driver using PWM with an Arduino.
*/
 
// Motor 1
const int M1PWM = 9;  // PWM Pin
const int M1DIR = 8;  // Direction Pin
 
// Motor 2
const int M2PWM = 10;  // PWM Pin
const int M2DIR = 7;  // Direction Pin
 
void setup() {
  // Set all the motor control pins as outputs
  pinMode(M1DIR, OUTPUT);
  pinMode(M1PWM, OUTPUT);
  pinMode(M2DIR, OUTPUT);
  pinMode(M2PWM, OUTPUT);
}
 
void loop() {
  // Move motors forward at full speed
  digitalWrite(M1DIR, HIGH);
  analogWrite(M1PWM, 255);
  digitalWrite(M2DIR, HIGH);
  analogWrite(M2PWM, 255);
  
  delay(2000);  // Wait for 2 seconds
 
  // Stop motors
  analogWrite(M1PWM, 0);
  analogWrite(M2PWM, 0);
  
  delay(2000);  // Wait for 2 seconds
  
  // Move motors backwards at full speed
  digitalWrite(M1DIR, LOW);
  analogWrite(M1PWM, 255);
  digitalWrite(M2DIR, LOW);
  analogWrite(M2PWM, 255);
  
  delay(2000);  // Wait for 2 seconds
  
  // Stop motors
  analogWrite(M1PWM, 0);
  analogWrite(M2PWM, 0);
  
  delay(2000);  // Wait for 2 seconds
}
 

Comments