Created
November 26, 2015 21:46
-
-
Save futureshocked/722cc1ed1cc66ff4ca60 to your computer and use it in GitHub Desktop.
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
/*############################################################################## | |
Author: | |
* Mirko Prosseda (06-2013) | |
* email: [email protected] | |
* Modified by Peter Dalmaris | |
Description: | |
* DC Dual Motor Driver 30V 4A V2 test sketch v1.0 | |
* Speed and direction for each motor channel are regulated by | |
* potentiometers attached to Arduino pins A0 and A1 | |
Connections: | |
* BOARD -> ARDUINO | |
* 1A -> 2 | |
* 1B -> 4 | |
* E1 -> 3 | |
##############################################################################*/ | |
// Define constants and variables | |
const int Dir1a = 2; | |
const int Dir1b = 4; | |
const int Enable1 = 3; | |
// Initialization | |
void setup() | |
{ | |
pinMode(Dir1a, OUTPUT); | |
pinMode(Dir1b, OUTPUT); | |
pinMode(Enable1, OUTPUT); | |
} | |
// main loop | |
void loop() | |
{ | |
for (int i=0;i<100;i++) | |
{ | |
analogWrite(Enable1,255); //go full speed | |
digitalWrite(Dir1a, HIGH); //towards one direction | |
digitalWrite(Dir1b, LOW); | |
delay(3000); | |
analogWrite(Enable1,255); //go full speed | |
digitalWrite(Dir1a, LOW); // and now towards the | |
digitalWrite(Dir1b, HIGH); //other direction | |
delay(3000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment