Created
September 8, 2020 17:08
-
-
Save tieubinhco/09b96b784aa9417bb7316db235dd076f to your computer and use it in GitHub Desktop.
Motor control Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void w1(int rotation, int direct) | |
{ | |
analogWrite(PWM1, rotation); | |
if (direct == 1) | |
{ | |
digitalWrite(IN1A, HIGH); | |
digitalWrite(IN2A, LOW); | |
} | |
else if (direct == -1) | |
{ | |
digitalWrite(IN1A, LOW); | |
digitalWrite(IN2A, HIGH); | |
} | |
} | |
void w2(int rotation, int direct) | |
{ | |
analogWrite(PWM2, rotation); | |
if (direct == 1) | |
{ | |
digitalWrite(IN1B, HIGH); | |
digitalWrite(IN2B, LOW); | |
} | |
else if (direct == -1) | |
{ | |
digitalWrite(IN1B, LOW); | |
digitalWrite(IN2B, HIGH); | |
} | |
} | |
void w3(int rotation, int direct) | |
{ | |
analogWrite(PWM3, rotation); | |
if (direct == 1) | |
{ | |
digitalWrite(IN1C, HIGH); | |
digitalWrite(IN2C, LOW); | |
} | |
else if (direct == -1) | |
{ | |
digitalWrite(IN1C, LOW); | |
digitalWrite(IN2C, HIGH); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment