VNH2SP30 Motor Driver Carrier MD01B
VNH2SP30 Motor Driver Carrier MD01B
VNH2SP30 Motor Driver Carrier MD01B connector description
This module used for drive a DC motor. Pin that needs to connected is PWM, IN A, IN B, OUT A, OUT B, +5 V, and GND.
Sample code:
#define InA_PIN 4 //Yellow #define InB_PIN 5 //Blue #define PWM_PIN 3 //Green //INA 1 INB 0 clockwise FORWARD //INA 0 INB 1 counterclockwise REVERSE void setup() { // put your setup code here, to run once: pinMode(InA_PIN, OUTPUT); pinMode(InB_PIN, OUTPUT); pinMode(PWM_PIN, OUTPUT); analogWrite(PWM_PIN, 0); digitalWrite(InA_PIN, HIGH); digitalWrite(InB_PIN, LOW); } void loop() { // put your main code here, to run repeatedly: digitalWrite(InA_PIN, HIGH); digitalWrite(InB_PIN, LOW); analogWrite(PWM_PIN, 255); delay(2000); digitalWrite(InA_PIN, LOW); digitalWrite(InB_PIN, HIGH); analogWrite(PWM_PIN, 127); delay(5000); }
If IN A is high and IN B is low then the motor will drive forward. But if IN A is low and IN B is high then the motor will drive backward. For a control speed use duty cycle of PWM as a speed in percent.
From this code will drive forward 100% 2 seconds and then drive backward 50% 5 seconds.
Comments
Post a Comment