Created
August 4, 2022 20:00
-
-
Save kostyay/563285c171d5a24934a9f58bbce9855a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/BTS7960 motor driver sketch | |
int R_IS = 1; | |
int R_EN = 2; | |
int R_PWM = 3; | |
int L_IS = 4; | |
int L_EN = 5; | |
int L_PWM = 6; | |
void setup() { | |
Serial.begin(9600); | |
// put your setup code here, to run once: | |
pinMode(R_IS, OUTPUT); | |
pinMode(R_EN, OUTPUT); | |
pinMode(R_PWM, OUTPUT); | |
pinMode(L_IS, OUTPUT); | |
pinMode(L_EN, OUTPUT); | |
pinMode(L_PWM, OUTPUT); | |
digitalWrite(R_IS, LOW); | |
digitalWrite(L_IS, LOW); | |
digitalWrite(R_EN, HIGH); | |
digitalWrite(L_EN, HIGH); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
int i; | |
for(i = 0; i <= 255; i= i+10){ //clockwise rotation | |
Serial.write("clockwise\n"); | |
analogWrite(R_PWM, i); | |
analogWrite(L_PWM, 0); | |
delay(500); | |
} | |
delay(500); | |
for(i = 0; i <= 255; i= i+10){ //counter clockwise rotation | |
Serial.write("unclockwise\n"); | |
analogWrite(R_PWM, 0); | |
analogWrite(L_PWM, i); | |
delay(500); | |
} | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment