Last active
November 18, 2018 21:11
-
-
Save giljr/11d975c1b8a5367609018dd3c4e058f6 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
| /* | |
| BTS 7960B | |
| */ | |
| int RPWM1 = 5; // Two board used here, 1 | |
| int LPWM1 = 6; | |
| int L_EN1 = 7; | |
| int R_EN1 = 8; | |
| int RPWM2 = 9; // and 2 | |
| int LPWM2 = 10; | |
| int L_EN2 = 11; | |
| int R_EN2 = 12; | |
| void setup() { | |
| for (int i = 5; i < 12; i++) { // Configure pins 5,6,7,8,9,10,11 as Output | |
| pinMode(i, OUTPUT); | |
| } | |
| for (int i = 5; i < 12; i++) { // Configure pins 5,6,7,8,9,10,11 as digital LOW signal | |
| digitalWrite(i, LOW); | |
| } | |
| delay(10); | |
| digitalWrite(R_EN1, HIGH); // Enable all pins | |
| digitalWrite(L_EN1, HIGH); | |
| digitalWrite(R_EN2, HIGH); | |
| digitalWrite(L_EN2, HIGH); | |
| } | |
| void loop() { | |
| delay(10); | |
| for (int i = 0; i < 256; i++) { // accelerates to maximum | |
| analogWrite(RPWM1, i); | |
| analogWrite(RPWM2, i); | |
| // analogWrite(LPWM1,255-i); | |
| // analogWrite(LPWM2,255-i); | |
| delay(100); | |
| } | |
| delay(10); | |
| for (int i = 255; i > 0; i--) { // slows to a stop | |
| analogWrite(RPWM1, i); | |
| analogWrite(RPWM2, i); | |
| // analogWrite(LPWM1,255-i); | |
| // analogWrite(LPWM2,255-i); | |
| delay(100); | |
| } | |
| delay(10); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment